Re: many constructors in a class?

2013-08-15 Thread Steven D'Aprano
On Wed, 14 Aug 2013 14:16:31 +, climb65 wrote: 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.

Re: many constructors in a class?

2013-08-15 Thread Fábio Santos
I agree with Steven here. classmethod is the best practise, most practical, readable, future-proof, one obvious way to do it. On 15 Aug 2013 08:29, Steven D'Aprano st...@pearwood.info wrote: On Wed, 14 Aug 2013 14:16:31 +, climb65 wrote: Hello, here is a small basic question : Is

Re: many constructors in a class?

2013-08-15 Thread Roy Smith
In article 520c81f6$0$29885$c3e8da3$54964...@news.astraweb.com, Steven D'Aprano st...@pearwood.info wrote: [1] The constructor is __new__, not __init__. __init__ is called to initialise the instance after __new__ constructs it. True, but be warned that writing your own __new__() is quite

many constructors in a class?

2013-08-14 Thread climb65
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. --

Re: many constructors in a class?

2013-08-14 Thread Phil Le Bienheureux
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

Re: many constructors in a class?

2013-08-14 Thread duncan smith
On 14/08/13 15:16, climb65 wrote: 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

Re: many constructors in a class?

2013-08-14 Thread Beth McNany
On Wed, Aug 14, 2013 at 10:16 AM, climb65 clim...@laposte.net wrote: 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++