no return values for __init__ ??

Aahz Maruch aahz at netcom.com
Fri Jan 7 15:30:51 EST 2000


In article <3875099A.2CF9333C at mdlink.de>, Helge Hess  <helge at mdlink.de> wrote:
>Aahz Maruch wrote:
>> In article <3874CFE5.765A40EA at mdlink.de>,
>> Helge Hess  <helge.hess at mdlink.de> wrote:
>>>
>>>recently I was heavily wondering why __init__ does not allow return
>>>values ! Is there any special reason not to do this ?
>> 
>> Yup.  The return value *has* to be the object instantiated by Python.
>
>No, the return value has to be None, which is the default return value
>as well. The only thing enforcing this from a technical point of view is
>a simple
>
>  if (ret != Py_None)
>    throw exception
>
>in the PyInstance_New() function. The 'fix' is just
>
>  if ((ret == Py_None) || (ret == self))
>    decref(ret), return self
>  else
>    decref(self), return ret
>
>This doesn't break compatibility to any valid Python code.

Not directly, no.  I think it breaks compatibility with Python's
extremely simple object model and I would be surprised if Guido
disagrees with me.
--
                      --- Aahz (@netcom.com)

Androgynous poly kinky vanilla queer het    <*>     http://www.rahul.net/aahz/
Hugs and backrubs -- I break Rule 6

The problem with an ever-changing .sig is that you have to keep changing it.



More information about the Python-list mailing list