← Back to videos

Mock interview with Semyon for the role of Junior Python developer

Interview timeline Click any block to jump

Interview breakdown

Interviewer verdict
Passed with caveats Level: Borderline Junior (5.5–6/10: solid live code reasoning, shallow OOP theory)

The interviewer gave a borderline pass ('more yes than no', 5.5–6/10): theoretical OOP answers were shallow and relied on appeals to authority, but on the tricky obj.__class__ reassignment task the candidate stayed composed, analyzed runtime behavior logically, and independently deduced that the new class's instance attribute was missing because __init__ was bypassed.

Candidate: Semyon
Target role: Junior Python Developer

22 y/o · Master's student in ML with a CS bachelor's degree, working in IT support at Sber

Answers accuracy 14 total
57% score
Theory
3/8 correct · 62%
Live coding
3/6 correct · 50%
Practical task
Partially solved

Dynamic instance class reassignment (obj.__class__ = B): methods, attributes, and bypassing __init__

The candidate properly instantiated the class, called its method, and distinguished the __class__ attribute from a method, though he initially expected errors on obj.__class__ = B and on reading old attribute obj.x. After seeing the output, he independently deduced the mechanism: reassigning __class__ switches method and class-attribute lookup to B without invoking B.__init__, keeping x in the instance while obj.y raises AttributeError.

Topics covered Click a topic to filter questions

Candidate strengths

  • + Calm, confident interview demeanor and constructive reasoning under probing questions
  • + Strong live code analysis: after obj.__class__ = B, independently deduced why old attribute x persisted while y raised AttributeError (__init__ was bypassed)
  • + Clear grasp of instance vs class attributes and the respective roles of __new__ and __init__
  • + Ability to learn in real time during the interview by testing and refining hypotheses

Areas to improve

  • → Replace appeals to authority ('seniors say so / just my opinion') with causal reasoning and hands-on experimentation
  • → Understand trade-offs between OOP and functional programming rather than treating OOP as universally superior
  • → Sharpen Python object-model terminology: clearly separate variable names, runtime objects, and classes
  • → Study real-world dunder protocols and abstract base classes (abc module) beyond textbook examples

Questions in this interview

14 / 14
01 ▶ 02:53
What is object-oriented programming in plain terms and what problem does it solve?
Theory OOP, classes & dunder methods
?
Candidate's answer

Described modeling entities via classes with attributes and methods and named polymorphism, inheritance, and encapsulation, but struggled to articulate concrete benefits beyond vague 'flexibility'.

Key takeaway

OOP bundles state and behavior behind clear interfaces, helping manage state transitions, invariants, and extensibility in complex domains.

Open moment on YouTube ↗
#01
02 ▶ 05:10
Is it true that function behavior cannot be extended like class inheritance, and what are decorators for?
Theory Decorators, iterators, generators & context managers
?
Candidate's answer

Initially claimed functions cannot be extended without rewriting them, then immediately corrected himself when reminded of decorators wrapping a function without modifying its body.

Key takeaway

Functional code extends and reuses behavior through function composition, closures, and higher-order functions such as Python decorators.

Open moment on YouTube ↗
#02
03 ▶ 07:59
Is OOP better than functional programming, and how should you choose between them in multi-paradigm Python?
Theory Algorithms, code reading & engineering practices
?
Candidate's answer

Correctly noted Python supports both paradigms, but claimed OOP is strictly better and should always be chosen because 'industry veterans say so'.

Key takeaway

Paradigms are tools with trade-offs: OOP fits stateful domain entities and polymorphic interfaces, while pure functions excel at stateless data transformations; idiomatic Python mixes both.

Open moment on YouTube ↗
#03
04 ▶ 11:33
What is the difference between an object, a class, a data type, and a variable in Python?
Theory Data types, numbers & memory
?
Candidate's answer

Defined an object as a class instance and a data type via valid operations, but got tangled and equated an object with a variable.

Key takeaway

In Python 3, classes and types are unified; an object is a concrete instance allocated in memory, whereas a variable is merely a name binding pointing to an object.

Open moment on YouTube ↗
#04
05 ▶ 14:04
Where do all classes in Python originate from, and what is built-in 'object'?
Theory OOP, classes & dunder methods
?
Candidate's answer

Correctly explained that all classes inherit from the built-in root class object providing default dunder methods, and stood firm that object is a class despite its name.

Key takeaway

Every class in Python 3 implicitly inherits from object, which supplies default dunder methods, while the metaclass type constructs class objects themselves.

Open moment on YouTube ↗
#05
06 ▶ 15:15
What is an abstract class, how does it differ from a concrete class, and why is it used in design?
Theory OOP, classes & dunder methods
?
Candidate's answer

Explained the design role of an abstract base class defining shared interface methods for concrete subclasses, but mistakenly remarked that Python still lets you instantiate an abstract class.

Key takeaway

Python defines abstract base classes via abc.ABC and @abstractmethod; attempting to instantiate a class with unimplemented abstract methods raises TypeError.

Open moment on YouTube ↗
#06
07 ▶ 18:37
What are dunder methods, how do __new__ and __init__ differ, and what is considered the constructor in Python?
Theory OOP, classes & dunder methods
?
Candidate's answer

Explained special methods invoked implicitly by Python syntax, accurately separated instance allocation in __new__ from attribute initialization in __init__, and noted the ambiguity of 'constructor' in Python.

Key takeaway

Instantiation runs in two phases: __new__(cls, ...) actually allocates and returns the new instance (the true allocator/constructor), and __init__(self, ...) initializes its state.

Open moment on YouTube ↗
#07
08 ▶ 21:28
How do you instantiate class A, call its method, inspect its class via __class__, and distinguish an attribute from a method?
Live coding OOP, classes & dunder methods
?
Candidate's answer

Promptly wrote obj = A() and obj.method(), clarified that __class__ is a data attribute rather than a method, and accurately distinguished attributes from callable methods.

Key takeaway

The special attribute obj.__class__ holds a reference to the instance's class object, printing <class '__main__.A'>.

Open moment on YouTube ↗
#08
09 ▶ 24:24
What happens if you assign obj.__class__ = B on an existing instance of A and call obj.method()?
Live coding OOP, classes & dunder methods
?
Candidate's answer

Confidently predicted an access error due to the double underscores and was surprised when the assignment succeeded and invoked B.method().

Key takeaway

For standard heap-allocated Python classes, __class__ is writable: reassigning it dynamically retargets method resolution to the new class.

Open moment on YouTube ↗
#09
10 ▶ 29:55
Why does obj.x still return 10 from class A after reassigning obj.__class__ = B?
Live coding OOP, classes & dunder methods
?
Candidate's answer

Predicted AttributeError assuming an instance of B shouldn't have attribute x, and was initially baffled when 10 was printed.

Key takeaway

Instance attributes live in the object's own obj.__dict__ dictionary, which remains untouched when obj.__class__ is reassigned.

Open moment on YouTube ↗
#10
11 ▶ 31:25
Will obj.y (set inside B.__init__) exist on the object after obj.__class__ = B?
Live coding OOP, classes & dunder methods
?
Candidate's answer

Accurately predicted AttributeError and explained why: assigning obj.__class__ = B only rebinds the class pointer without calling B(), so B.__init__ never ran to create self.y.

Key takeaway

__init__ only runs during normal class instantiation B(); mutating __class__ retypes an existing instance without populating new instance attributes.

Open moment on YouTube ↗
#11
12 ▶ 36:02
How do instance and class attributes differ, and will obj.y resolve after obj.__class__ = B if y is a class attribute on B?
Live coding OOP, classes & dunder methods
?
Candidate's answer

Clearly separated per-instance attributes from shared class attributes, and correctly concluded that defining y on class B outside __init__ makes obj.y accessible immediately.

Key takeaway

When 'y' is absent from obj.__dict__, attribute lookup falls back to obj.__class__ (B.__dict__) and its MRO, resolving class-level attributes on B immediately.

Open moment on YouTube ↗
#12
13 ▶ 39:00
Can you assign literally any class in Python to obj.__class__, or are there runtime restrictions?
Live coding OOP, classes & dunder methods
?
Candidate's answer

Guessed that only assigning a subclass might fail due to inheritance dependency loops, missing CPython's actual memory-layout constraints.

Key takeaway

__class__ assignment requires heap types with compatible C-level memory layouts; assigning built-in types (like int or str) or classes with incompatible __slots__ raises TypeError.

Open moment on YouTube ↗
#13
14 ▶ 40:22
How many core OOP pillars are there, and must every OOP codebase use all of them?
Theory OOP, classes & dunder methods
?
Candidate's answer

Added abstraction as the fourth pillar alongside encapsulation, inheritance, and polymorphism, and sensibly stated they should only be introduced when the problem warrants them.

Key takeaway

The four classic OOP pillars are abstraction, encapsulation, inheritance, and polymorphism; pragmatic engineering favors simple classes and composition over premature inheritance hierarchies.

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

In this episode I conduct a mock interview with a new candidate. Semyon is studying in a Master's program in ML, works in support (Sber) and already has experience with Python.

The main focus of the interview — OOP in Python: how the candidate understands objects and classes, why OOP is needed, what abstraction, encapsulation, inheritance and polymorphism are. And we also move to code and analyze a very unusual moment: what happens if "change" an object's class through __class__ — why methods start working from a different class, but attributes remain from the old one.

The video is useful if you:
• are preparing for a Junior Python interview
• are confused about OOP and terminology
• want to understand how the interviewer "digs deeper"
• like analysis of real situations and non-standard edge cases in Python

If it was helpful — like and subscribe.

Timestamps:

00:00 Greeting and interview plan
00:29 Introduction of participants
02:53 Theoretical questions
21:26 Working with code
43:17 Feedback exchange

#python #oop #interview #junior #pythoninterview #analysis #developer #programming