How to implement multiple constructors

2005-05-08 Thread tron . thomas
I am a C++ developer with only a little experience using Python. I want to create a Python class where by I can construct an instance from that class based on one of two different object types. For example, if I were programming in C++, I would do the something like the following: class MyClass

Re: How to implement multiple constructors

2005-05-08 Thread Steven Bethard
[EMAIL PROTECTED] wrote: I am a C++ developer with only a little experience using Python. I want to create a Python class where by I can construct an instance from that class based on one of two different object types. For example, if I were programming in C++, I would do the something

Re: How to implement multiple constructors

2005-05-08 Thread James Stroud
On Sunday 08 May 2005 03:05 pm, [EMAIL PROTECTED] wrote: I am a C++ developer with only a little experience using Python. I want to create a Python class where by I can construct an instance from that class based on one of two different object types. For example, if I were programming in

Re: How to implement multiple constructors

2005-05-08 Thread James Stroud
On Sunday 08 May 2005 03:28 pm, James Stroud wrote:    try:      self.avalue = isinstance.get_avalue()    except NameError:      self.avalue = isinstance.get_anothervalue() I have no idea where I copied those isinstances from. Also, the except should be an AttributeError. Here is a retry:  

Re: How to implement multiple constructors

2005-05-08 Thread J C Lawrence
[EMAIL PROTECTED] wrote: I am a C++ developer with only a little experience using Python. I want to create a Python class where by I can construct an instance from that class based on one of two different object types. The approaches I've seen used are to use a new class method as an

Re: How to implement multiple constructors

2005-05-08 Thread Steven Bethard
James Stroud wrote: If you know what type of object object is (BTW, a keyword in 2.3 and later, I believe) Not a keyword, but a builtin as of 2.2. STeVe -- http://mail.python.org/mailman/listinfo/python-list