4. Object Property
• __dir__
• builtin function:dir
• __hash__
• builtin function:hash
• __sizeof__
• the internal size of the object in bytes
5. Object Attribute
• __setattr__、__delattr__
• similar the builtin function - setattr and delattr
• __getattribute__
• Called unconditionally
• call __getattr__ next if - 1) raise AttributeError or 2) direct call
• __getattr__
• will NOT call if attribute can be get by normal mechanism
7. Object Instance
• __class__
• the class to which a instance belongs
• after 3.5 __class__ is writable
• __new__
• object.__new__ is a static method
• create and return a new object
• __init__
• The first method called when instance created
8. Metaclass in Python
• __metaclass__
• https://stackoverflow.com/questions/100003/what-
are-metaclasses-in-python
9. Inheritance
• __init_subclass__
• call when inherited, event not initialization
• __subclasshook__
• return True、False、NotImplementedError
• check is subclass or not
10. Python Serialization
• __reduce__
• return the String or the Tuple
• string names a global variable
• tuple must be between two or three
• first is callable and second is the argument
• __reduce_ex__
• protocol version
12. More __XXX__
• basic arithmetic operator and comparison
• slice and list indexing
• …
13. First Class Citizen
• First-Class Object / First-Class Citizen
• Pass to other variable, function
• As the return value
• Can created in run-time
• Exist without assigned name