__init__ return value

Skip Montanaro skip at pobox.com
Wed Sep 24 15:28:38 EDT 2003


    >> No, __init__ method return values are always ignored.

    Bob> Oh?

    >>>> class A:
    Bob> ...     def __init__(self):
    Bob> ...             return 'asdf'
    Bob> ...
    >>>> A()
    Bob> Traceback (most recent call last):
    Bob>    File "<interactive input>", line 1, in ?
    Bob> TypeError: __init__() should return None

My apologies.  It is checked and an exception raised if it's not None.
That's an implementation detail, not a property of the language.

Skip






More information about the Python-list mailing list