Re: return None in constructor call?

Guido.van.Rossum@cwi.nl
Sun, 21 Nov 1993 18:28:25 +0100

> > Is there some reason the Some_Class __init__ routine isn't allowed
> > to return 'self' in some form?
>
> Maybe because __init__ is a magical method, and Python "just knows" to
> return the self it passed to __init__ to begin with. Agreed it's not
> obvious ...

Why isn't it obvious? I have a feeling that all this confusion stems
from the old convention to have an "init()" method which *did* have to
return self to be useful. Under the new scheme, an __init__() method
no more needs to return "self" than a constructor in C++ need return
anything. In fact it would be quite annoying if a constructor
returned anything at all, since constructors of derived classes
generally need to call the constructor of their base class(es), and if
these constructors returned anything their caller would have to "void"
that (else it would be printed as any non-void expression is).

--Guido van Rossum, CWI, Amsterdam <Guido.van.Rossum@cwi.nl>