Alexandre Vassalotti wrote: > On Thu, Oct 30, 2008 at 1:00 PM, Fred Drake <[EMAIL PROTECTED]> wrote: >> It's good to move work into __init__ where reasonable, so that it can be >> avoided if a subclass wants it done in a completely different way, but new >> can't work that way. >> > > And that is exactly the reason why, the _pickle module doesn't use > __new__ for initialization. Doing any kind of argument parsing in > __new__ prevents subclasses from customizing the arguments for their > __init__.
No it doesn't - it just means the subclasses have to override __new__ as well and then give the parent class the arguments it needs. I've used this convention (*must* call parent class __new__ or the instance will be broken, may call parent class __init__ if it is helpful) many times, and it is far more robust than relying on subclasses to remember to call the parent class __init__ when setting up the class. Cheers, Nick. -- Nick Coghlan | [EMAIL PROTECTED] | Brisbane, Australia --------------------------------------------------------------- _______________________________________________ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com