[Tutor] When to use __new__ vs. __init__ ?
Kent Johnson
kent37 at tds.net
Fri Apr 18 19:18:06 CEST 2008
On Fri, Apr 18, 2008 at 12:08 PM, <python at bdurham.com> wrote:
> Any guidelines on when to use __new__ vs. __init__ when sub-classing?
>
Generally use __init__(). The only use-case for __new__() that I can think
of is when you subclass immutable classes like str or int you generally have
to use __new__() because __init__() is too late.
Kent
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/tutor/attachments/20080418/f57ec730/attachment.htm
More information about the Tutor
mailing list