← Back to videos

Junior Python interview: the candidate has a stronger grasp of OOP than is typical for a junior level

Interview timeline Click any block to jump

Interview breakdown

Interviewer verdict
Passed interview Level: Junior+ / approaching Middle

The candidate passed with flying colors, demonstrating an understanding of Python's object model, metaclasses, and MRO well above the Junior bar (earning an invitation to a Middle-level mock interview). The main area for improvement is interview communication style: keeping answers concise and conversational rather than delivering extended monologues.

Candidate: Alexey
Target role: Junior Python Developer

Started programming in C, now focused on Python · self-taught with no prior formal commercial engineering employment

Answers accuracy 12 total
92% score
Theory
9/9 correct · 100%
Live coding
2/3 correct · 67%
Practical task
Solved

Dynamic class creation via 3-argument metaclass call type(name, bases, dict)

Aside from a minor slip thinking empty tuple bases = () needed a comma, the candidate nailed the entire task: accurately explained all three arguments of type(name, bases, suspicious_dict), predicted that C is a newly created class WTF with class attribute x = 12 whose own type(C) is <class 'type'>, and explained how to inject methods via the namespace dict.

Topics covered Click a topic to filter questions

Candidate strengths

  • + Deep, systematic grasp of Python's object model (relationships among object, classes, metaclass type, and __call__)
  • + Consistent, rock-solid reasoning that held up under repeated devil's-advocate follow-ups from different angles
  • + Clear command of multiple inheritance pitfalls, the diamond problem, and C3 MRO linearization
  • + Strong code-reading skills: immediately recognized dynamic class construction via 3-argument type(name, bases, dict)

Areas to improve

  • → Keep answers concise: lead with a direct summary and let the interviewer ask for deeper elaboration
  • → Avoid long monologues that consume interview time and prevent the interviewer from covering their planned rubric
  • → Practice conversational pacing for behavioral / soft-skills rounds at large tech companies
  • → Brush up on minor syntax edge cases such as empty tuple literal () vs single-element tuple (x,)

Questions in this interview

12 / 12
01 ▶ 03:16
What is a class in Python and what core responsibilities does it fulfill?
Theory OOP, classes & dunder methods
?
Candidate's answer

Outlined four roles: an instance factory, a namespace bundling data abstractions with their methods, storage for shared class attributes, and a unit of inheritance.

Key takeaway

A Python class encapsulates shared state, method behavior, inheritance relationships, and instance construction (__new__ / __init__).

Open moment on YouTube ↗
#01
02 ▶ 06:13
Where do objects and classes come from in Python, and how do 'object' and 'type' sit at the root of the model?
Theory Python internals, bytecode & runtime
?
Candidate's answer

Explained that all data in Python are objects: instances come from classes, classes themselves are objects created by metaclass 'type', and root 'type' and 'object' are bootstrapped in C.

Key takeaway

In CPython, every class subclasses 'object' (issubclass), while every class — including 'object' and 'type' itself — is an instance of metaclass 'type' (isinstance).

Open moment on YouTube ↗
#02
03 ▶ 09:25
What is a metaclass, and how do you define a custom metaclass in Python to customize class creation?
Theory OOP, classes & dunder methods
?
Candidate's answer

Used a clear 'machine -> factory -> factory of factories' analogy and explained subclassing 'type' while overriding dunder methods and delegating via super().

Key takeaway

A custom metaclass subclasses 'type', customizes __new__ or __init__, and hooks into class definitions via 'class MyClass(metaclass=MyMeta):'.

Open moment on YouTube ↗
#03
04 ▶ 13:16
How does attribute lookup work across inheritance, and why use classes at all when functions and modules already enable code reuse?
Theory OOP, classes & dunder methods
?
Candidate's answer

Described instance -> class -> superclass lookup and illustrated with Employee/Manager types how OOP co-locates data with valid operations and scales polymorphic behavior cleanly.

Key takeaway

OOP provides polymorphism and encapsulation: a new subclass works seamlessly wherever the base type is expected while localizing overridden behavior.

Open moment on YouTube ↗
#04
05 ▶ 22:08
What hazards come with multiple inheritance (the diamond problem), and how does Python solve them?
Theory OOP, classes & dunder methods
?
Candidate's answer

Clearly explained how naive depth-first left-to-right lookup mishandled diamond hierarchies and how Python's C3 MRO linearization visits sibling subclasses before their shared ancestor.

Key takeaway

C3 linearization builds cls.__mro__ so that subclasses always precede their base classes and shared ancestors are visited only after all branches.

Open moment on YouTube ↗
#05
06 ▶ 28:04
Since everything in Python is an object, can a class inherit from an ordinary class instance?
Theory OOP, classes & dunder methods
?
Candidate's answer

Rejected the premise cleanly: every class is an object, but not every object is a class, so inheritance requires a class/metaclass (such as abc.ABC) rather than an ordinary instance.

Key takeaway

Base classes must be type instances (or objects implementing __mro_entries__ like Generic); inheriting from an ordinary instance raises TypeError.

Open moment on YouTube ↗
#06
07 ▶ 31:10
How can you check an object's class, what do leading underscores mean, and what happens if you reassign obj.__class__?
Theory OOP, classes & dunder methods
?
Candidate's answer

Named type(obj) and __class__, explained single leading underscore _attr as a non-public API convention, and noted reassigning __class__ can alter method dispatch within compatible layouts.

Key takeaway

Prefer isinstance(obj, Cls) for polymorphic type checks and type(obj) for exact class identity; reassigning __class__ works only across heap types with compatible memory layouts.

Open moment on YouTube ↗
#07
08 ▶ 34:46
How can calling metaclass type(obj) return an object's type instead of creating a class, and what powers the () call syntax?
Theory OOP, classes & dunder methods
?
Candidate's answer

Correctly deduced that 'type' dispatches on argument count (1 arg inspects type, 3 args construct a class) and explained that () always invokes __call__ defined on the object's class/metaclass.

Key takeaway

Built-in 'type' has two signatures: type(obj) returns the object's class, while type(name, bases, dict) constructs a new class; calling any class Cls() invokes type.__call__.

Open moment on YouTube ↗
#08
09 ▶ 41:17
How do __str__ and __repr__ differ in Python, and why do both exist?
Theory OOP, classes & dunder methods
?
Candidate's answer

Explained that __str__ formats readable end-user text for print(), whereas __repr__ provides unambiguous developer/debug output, renders elements inside containers, acts as fallback when __str__ is absent, and ideally reconstructs the object.

Key takeaway

Implementing __repr__ covers both repr() and fallback str()/print(), whereas implementing only __str__ leaves repr() and container printing with the default <... at 0x...> string.

Open moment on YouTube ↗
#09
10 ▶ 44:35
Does assigning empty parentheses bases = () cause a SyntaxError in Python?
Live coding Collections, lists, dicts & hash tables
?
Candidate's answer

Mistakenly predicted a SyntaxError on bases = (), confusing empty tuple syntax with single-element tuple syntax.

Key takeaway

An empty tuple is written () (whereas (,) is a SyntaxError); a trailing comma is required only for a 1-element singleton tuple (x,).

Open moment on YouTube ↗
#10
11 ▶ 46:05
What does C = type('WTF', (), {'x': 12}) create, and what do print(C) and print(type(C)) output?
Live coding OOP, classes & dunder methods
?
Candidate's answer

Correctly explained all three arguments: it dynamically creates class WTF with class attribute x = 12, print(C) outputs <class '__main__.WTF'>, and print(type(C)) outputs <class 'type'>.

Key takeaway

A standard 'class WTF: x = 12' statement is syntactic sugar that invokes type('WTF', (), {'x': 12, ...}) at runtime.

Open moment on YouTube ↗
#11
12 ▶ 53:31
How can you attach methods when creating a class dynamically with type(name, bases, dict), and when is this used in practice?
Live coding OOP, classes & dunder methods
?
Candidate's answer

Explained passing a function object (uninvoked) under a string key in the namespace dict, and noted this pattern belongs in class factories/frameworks rather than everyday business code.

Key takeaway

Functions placed in the namespace dict automatically behave as bound methods via the descriptor protocol — a technique used internally by ORM models, dataclasses, and namedtuple.

Open moment on YouTube ↗
#12
Original video description & timecodes

A mock interview for the role of Junior Python Developer, focusing on OOP and the inner workings of Python. We discussed classes, objects, metaclasses, inheritance, type(), dynamic class creation, as well as the magic methods __str__ and __repr__. Finally, there is a detailed analysis of the candidate’s answers and feedback not only on the technical aspects but also on soft skills during the interview.

Timecodes:
00:00 — Start
00:11 — Introduction of participants
01:35 — How the interview will proceed
03:16 — What is a class in Python
06:13 — Objects, classes and metaclasses
09:25 — What is a metaclass
13:16 — Inheritance in Python
22:08 — Multiple inheritance and its issues
28:04 — Can an object be inherited from?
31:10 — How to determine an object’s class
34:46 — What is type() and how does it work?
41:17 — __repr__ and __str__
44:21 — Practical exercise: analysing code with type()
53:31 — Dynamic creation of attributes and methods
57:26 — Moving on to feedback
59:17 — Feedback on the interview