Metaclasses(Draft)#
Attributes, Lookup, Bound Methods#
code/attributes.py
code/descriptor-bound-method.py
Todo#
class
__new__
__init__
__getattr__(self, name)
fallback if attr found nowhere (neither instance, nor class hierarchy)
__getattribute__
called before lookup
if raises AttributeError, python calls __getattr__
super
descriptors
https://docs.python.org/3/howto/descriptor.html
descriptor protocol -> doc
__get__, __set__, __delete__
livehack: write own @property
code/descriptor.py
code/descriptor-bound-method.py (function vs. bound method)
class method is a plain function. actually a descriptor that returns a bound method on __get__
f.bar()
f.__dict__ is empty
bar found in Foo -> function
ich checks nimmer