Re: [SQLObject] New style classes and __init__ vs _init
SQLObject is a Python ORM.
Brought to you by:
ianbicking,
phd
From: Bud P. B. <bu...@si...> - 2003-06-03 18:47:02
|
Hi Edmund, I think what I know about this issue, I read from either in Andrew Kuchlin's What's new in 2.2 http://www.python.org/doc/2.2.1/whatsnew/ or in Guido's essay http://www.python.org/doc/2.2.1/whatsnew/ I agree with Ian that every time you call the class, both __new__ and __init__ of the class are executed. More precisely, if class C(object): def __init__(self): pass c = C() will translate to something along the following lines: c = C.__new__(C) followed by C.__init__(c) But as I pointed out before, calling the class is not the only way of ending up with a valid instance of C. It is possible, and often useful to just call __new__ and to initialize the state of the object (in most cases the value of __dict__) in a different way. This is what is done for example by pickle. --b On Mon, 02 Jun 2003 20:25:35 -0400 Edmund Lian <el...@in...> wrote: > In the SQLObject docs, Ian writes: > > "With new-style classes, __init__ is called everytime the class is > called. That means it's called when an object is just fetched from the > cache" > > This was a bit surprising to me, so I Googled to find discussion of > this, but came up empty. Can anybody point me to a discussion of this? > > ...Edmund. > > > > ------------------------------------------------------- > This SF.net email is sponsored by: eBay > Get office equipment for less on eBay! > http://adfarm.mediaplex.com/ad/ck/711-11697-6916-5 > _______________________________________________ > sqlobject-discuss mailing list > sql...@li... > https://lists.sourceforge.net/lists/listinfo/sqlobject-discuss > /----------------------------------------------------------------- | Bud P. Bruegger, Ph.D. | Sistema (www.sistema.it) | Via U. Bassi, 54 | 58100 Grosseto, Italy | +39-0564-411682 (voice and fax) \----------------------------------------------------------------- |