From: "Skip Montanaro" <skip@pobox.com> > >> [__class_init__] > > Tim> [Guido said] ... "The right way" is to define a custom metaclass > Tim> instead (whose __init__ plays the role __class_init__ would have > Tim> played if defined in the class). It makes sense to me, but I'll > Tim> have to play with it to be convinced it's as usable. > > For those of us with next to no ExtensionClass experience, I think it would > be helpful to describe what __class_init__ does. I saw it there in the > PyGtk 2.x wrappers before JamesH converted to new-style classes. I had no > idea what it did (and blissfully ignored it) and James apparently didn't > need any similar functionality after the conversion. __class_init__ (or was it called __init_class__?) is a *class* method which is called when the *class* is created (the class statement executed). class X(ExtensionClass.Base): def __class_init__(cls): print cls, "created" class Y(X): pass would first print '<extensionclass __main__.X> created' and then '<extensionclass __main__.Y> created'. It can be used to initialize class attributes for example depending on other class attributes (that's at least what I have/had in mind). Thomas
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4