I know that in Python it\'s possible to add at runtime a method to a class:
class Test:
def __init__(self):
self.a=5
test=Test()
import types
d
It's documented in Data model, section "Class Instances":
Attribute assignments and deletions update the instance’s dictionary, never a class’s dictionary. If the class has a
__setattr__()
or__delattr__()
method, this is called instead of updating the instance dictionary directly.
So no matter if old-style or new-style, those two checks are always made on the type, rather then the instance.