PEP for an unrestricted __init__ ?!

Terry Reedy tejarex at yahoo.com
Thu Apr 18 18:00:36 EDT 2002


"holger krekel" <pyth at devel.trillke.net> wrote in message
news:mailman.1019162616.18095.python-list at python.org...

To expand on JR's answer and identify your misconceptions:

> In python each new instance of a class is created by __init__

No, instance is first created by internal default constructor or
new-style user-supplied equivalent __new__().  Then __init__ is
called, if it exists, with new instance as first arg to initialize
that new instance.

> __init__ would then
> be allowed to return something other[1] than the implicite 'self'.

> [1] For backward compatibility we might need to treat
>     'return None' as 'return self' because __init__ currently
>     seems to follow this rule.

__init__ is called as a proceedure -- *any* return is ignored

Terry J. Reedy






More information about the Python-list mailing list