[I wrote] > > > What I want to avoid is > > > > > > class X(...): > > > .... > > > initialize(X) > > [and GvR asked] > > What would initialize(X) do that you can't write in the class body? > [finally Alex gave the answer] > I'm not sure, maybe use the class object X itself? That object > isn't available in the class body. For example, initialize(X) > could among other things enregister class object X with any > appropriate registrars, as above. But that may not be what > is meant, as "initialize" may be meant to imply that the > argument object is modified Exactly. Initialize(X) would for example calculate (initialize) certain class attributes from other class attributes. There are (even in the standard python library) usage patterns going like this: class X: _inited = 0 def __init__(self, ...): if not _inited: <code to set some class attributes> .... This is really not instance but class initialization, and it is deferred until the first instance has been created. What if someone need the (calculated) class attributes before this? > (and I don't understand why > one would need to avoid the example usage I proposed, > anyway). Which example? 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