[Python-Dev] How to suppress instance __dict__?

Delaney, Timothy C (Timothy) tdelaney at avaya.com
Sun Mar 23 23:02:43 EST 2003


> From: David Abrahams [mailto:dave at boost-consulting.com]
> >
> > I wouldn't say that. Use __init__ unless you *must* use __new__. And
> > when you use __new__, still use __init__ for initialisation.
> >
> > And if you are going to use __new__, you are expected to be able to
> > explain *why*.
> >
> > Pretty straightforward to me.
> 
> Why should that be the rule? Why not the opposite?
> 
> FWIW, if everyone used the opposite policy (__new__ unless you must
> use __init__), the problem of __del__ operating on uninitialized
> objects could be substantially relieved.

Because most of the time we want to work with fully-constructed objects. You can't use overridden methods in a constructor - only from an initialiser.

Tim Delaney





More information about the Python-list mailing list