How to use "__new__"?
steven.bethard at gmail.com
Wed Mar 30 03:12:41 CEST 2005
could ildg wrote:
> As there is already __init__, why need a __new__?
> What can __new__ give us while __init__ can't?
> In what situations we should use __new__?
> And in what situations we must use __new__?
> Can __new__ take the place of __init__?
I believe the current documentation will be updated when 2.4.1 is
released, but documentation for __new__ is now available at:
In short, you could use __new__ in place of __init__, but it's probably
only useful to do so if you need to change an instance *before* it's
created. In general, if you aren't subclassing an immutable type, and
you're not sure that you need __new__, you probably don't.
More information about the Python-list