W3
Teacher
Explore
Browse by field
Artificial Intelligence
Accounting & Finance
Information Technology
Show all fields
Interview Q&A
All Interview Questions
Beginner
Intermediate
Advanced
Practice
MCQs
Quizzes
Mock Interviews
About
Light
Dark
Auto
Sign in
Get Started
Search interview questions
Search
30 questions for “Descriptors & Properties”
Found in 1 field. Select a question to see its full answer.
Matching topics
Python
Descriptors
&
Properties
15
Information Technology
30 questions in 2 technologies
#
Question
Technology
Topic
Level
1
How do
properties
and
descriptors
interact with __slots__, and what special consideration is needed?
Python › Descriptors & Properties
Python
Descriptors
&
Properties
Advanced
2
What does the @property decorator do, and how does it let a method be accessed like an attribute?
Python › Descriptors & Properties
Python
Descriptors
&
Properties
Beginner
3
How do you add a setter to a property so assignment (obj.attr = value) triggers custom logic, like validation?
Python › Descriptors & Properties
Python
Descriptors
&
Properties
Beginner
4
How would you convert an existing plain attribute into a property later, without breaking any existing code that reads or writes it directly?
Python › Descriptors & Properties
Python
Descriptors
&
Properties
Beginner
5
What is a descriptor, and which dunder methods define the descriptor protocol?
Python › Descriptors & Properties
Python
Descriptors
&
Properties
Intermediate
6
What is the difference between a data descriptor and a non-data descriptor, and how does this affect attribute lookup priority?
Python › Descriptors & Properties
Python
Descriptors
&
Properties
Intermediate
7
How does __set_name__ let a descriptor automatically learn the attribute name it's being assigned to on the owning class?
Python › Descriptors & Properties
Python
Descriptors
&
Properties
Intermediate
8
How would you implement a lazy, cached property using a custom descriptor (or functools.cached_property) that only computes its value once?
Python › Descriptors & Properties
Python
Descriptors
&
Properties
Advanced
9
How do you write a descriptor that behaves differently when accessed on the CLASS itself versus on an INSTANCE?
Python › Descriptors & Properties
Python
Descriptors
&
Properties
Advanced
10
How would you implement a type-validating descriptor that enforces a specific type constraint, reusable across multiple attributes and classes?
Python › Descriptors & Properties
Python
Descriptors
&
Properties
Advanced
Show all 30 questions in Information Technology