2013/8/14 climb65 <clim...@laposte.net>

> Hello,
>
> here is a small basic question :
>
> Is it possible to have more than one constructor (__init__ function) in a
> class? For instance, to create an object with 2 different ways? If my
> memory is good, I think that with C++ it is possible.
>
> Thanks for your answer.
> --
> http://mail.python.org/mailman/listinfo/python-list
>



Hello,

You have to use default values in __init__ function, like :
def __init__( self, name = None ):
        self.name_ = name

and afterwards in your code, test variable :
if self.name_:
       do something...

Regards,
Phil.
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to