Returning other instance from __init__ - I need help

Paulo da Silva psdasilvaX at esotericaX.ptX
Sat Mar 17 16:20:09 CET 2007

Gabriel Genellina escreveu:
> En Fri, 16 Mar 2007 22:05:05 -0300, Paulo da Silva
> <psdasilvaX at esotericaX.ptX> escribió:

> class C(object):
>     def __new__(cls, filename=None, foo=None, bar=None):
>         if filename is not None:
>             return cls.load(filename)
>         inst = super(C, cls).__new__(cls)

This makes the difference! I didn't know how to "build" an
instance inside __new__.

Thank you very much Gabriel.

More information about the Python-list mailing list