OOP Flashcards
1
Q
Initializer
A
__init__
2
Q
__init__
A
instance method that initializes a newly created object
3
Q
__dict__
A
dictionary or other mapping object used to store object’s attributes
MyClass.__dict__ for class attributes
obj.__dict__ for instance attributes
4
Q
Attribute Access Flow
A
- instance attributes
- class attributes
5
Q
Method Object
A
class MyClass: def func(self): ...
obj = MyClass()
obj.func - method object
MyClass.func - function object
6
Q
Class Method
A
@classmethod def method(cls): ...
can be called from an instance
7
Q
Static Method
A
@staticmethod def method(): ...
can be called from an instance
8
Q
__class__
A
reference to the class of an object
self.__class__
obj.__class__