|
|
|
People understand classes and objects. Objects are instances of a class and people "get" the idea that magic methods reside in the instance's class and not the instance.
Eyes start to cross when you talk about metaclasses. I've found that metclasses can be explained by using what people already know about classes and instances-of-classes. As it turns out classes are actually instances themselves - they are instances of their metaclass (which is almost always 'type'). So it shouldn't be surprising that the magic methods of a class reside in their metaclass.
Repeat that three times and change up the phrasing each time until the AHA moment sets in. A standard object is an instance of a class is an instance of a metaclass.
Do not, under any circumstances, mention that classes and metaclasses are co-equal types under the covers (though they are designed to be used differently). If your partner takes all that in stride do not mention that functions are valid in __metaclass__ assignments. Heads will asplode (the function thing is an implementation detail. I've never seen it used in practice).
Jack Diederich |
Homepage |
07/03/20 - 5:16 am | #
|
|
Now asplode is a cool word. 
Fuzzyman |
Homepage |
07/03/21 - 1:02 am | #
|
|
|
Commenting by HaloScan
|