[Python-Dev] Proper initialization of structs
Alexandre Vassalotti
alexandre at peadrop.com
Thu Oct 30 23:23:09 CET 2008
On Thu, Oct 30, 2008 at 1:00 PM, Fred Drake <fdrake at acm.org> 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__.
Although, I agree that __new__ should be used, whenever it is
possible, to initialize struct members.
-- Alexandre
More information about the Python-Dev
mailing list