object internals Flashcards
1
Q
dictionary of object attributes
A
__dict__
2
Q
when __getattr__ invoked
A
invokes when property not found by normal lookup
3
Q
when __getattribute__ invoked
A
instead of normal lookup
4
Q
method for setting attributes
A
__setattr__(self, item, value)
5
Q
method for deleting attributes
A
__delattr__(self, item)
6
Q
function to access __dict__
A
vars()
7
Q
special method with __getattribute__
A
repr(a) invoke a.__repr__ without __getattribute__
8
Q
get size of an object
A
sys.getsizeof(d)
9
Q
attribute of a class that reduce memory usage
A
__slots__