Re: Python OOP Problem

2009-12-29 Thread Laszlo Nagy
Thanks for reply, but it doesn't fit to my task. If I will add later other objects(and it will be very often) - I should stop the service, but that would be very bad. I think you meant if you add other classes. I'm not sure, if this is solution, but test passed: myimportmod =

Re: Python OOP Problem

2009-12-29 Thread Миклухо
On Dec 29, 7:35 pm, Laszlo Nagy gand...@shopzeus.com wrote: Thanks for reply, but it doesn't fit to my task. If I will add later other objects(and it will be very often) - I should stop the service, but that would be very bad. I think you meant if you add other classes. I'm not sure, if

Re: Python OOP Problem

2009-12-29 Thread Lie Ryan
On 12/29/2009 3:01 PM, Миклухо wrote: On 28 дек, 18:29, Martin v. Loewismar...@v.loewis.de wrote: In this case (you just started to learn Python), I recommend to take an explicit approach. Create a dictionary that maps class names to classes: name2class = { MyObject : MyObject,

Python OOP Problem

2009-12-28 Thread Миклухо
Hi, all. My problem is: 1) I have a database(postgresql) 2)I'm getting some string from database(string is a classname - written by me). 3)I need to construct new object from this string. In java it's done by Class.forName().newInstance(); For instance: 1)I receive the string: MyObject. 2)o =

Re: Python OOP Problem

2009-12-28 Thread Daniel Fetchinson
Hi, all. My problem is: 1) I have a database(postgresql) 2)I'm getting some string from database(string is a classname - written by me). 3)I need to construct new object from this string. In java it's done by Class.forName().newInstance(); For instance: 1)I receive the string: MyObject.

Re: Python OOP Problem

2009-12-28 Thread Martin v. Loewis
Миклухо wrote: Hi, all. My problem is: 1) I have a database(postgresql) 2)I'm getting some string from database(string is a classname - written by me). 3)I need to construct new object from this string. In java it's done by Class.forName().newInstance(); For instance: 1)I receive the

Re: Python OOP Problem

2009-12-28 Thread Anthony Tolle
On Dec 28, 7:29 am, Martin v. Loewis mar...@v.loewis.de wrote: In this case (you just started to learn Python), I recommend to take an explicit approach. Create a dictionary that maps class names to classes: name2class = { MyObject : MyObject,                MyOtherObject : MyOtherObject,  

Re: Python OOP Problem

2009-12-28 Thread Martin v. Loewis
name2class = { MyObject : MyObject, MyOtherObject : MyOtherObject, Etc : Etc } Then, when you receive the string class_name, you do o = name2class[class_name] o.myfunction() The class needs to be instantiated, so the one line should be as follows: o =

Re: Python OOP Problem

2009-12-28 Thread Миклухо
On 28 дек, 18:02, Daniel Fetchinson fetchin...@googlemail.com wrote: Hi, all. My problem is: 1) I have a database(postgresql) 2)I'm getting some string from database(string is a classname - written by me). 3)I need to construct new object from this string. In java it's done by

Re: Python OOP Problem

2009-12-28 Thread Миклухо
On 28 дек, 18:29, Martin v. Loewis mar...@v.loewis.de wrote: Миклухо wrote: Hi, all. My problem is: 1) I have a database(postgresql) 2)I'm getting some string from database(string is a classname - written by me). 3)I need to construct new object from this string. In java it's done by

Re: Python OOP Problem

2009-12-28 Thread Миклухо
On 28 дек, 18:29, Martin v. Loewis mar...@v.loewis.de wrote: Миклухо wrote: Hi, all. My problem is: 1) I have a database(postgresql) 2)I'm getting some string from database(string is a classname - written by me). 3)I need to construct new object from this string. In java it's done by

Re: Python OOP Problem

2009-12-28 Thread Миклухо
On 28 дек, 18:29, Martin v. Loewis mar...@v.loewis.de wrote: Миклухо wrote: Hi, all. My problem is: 1) I have a database(postgresql) 2)I'm getting some string from database(string is a classname - written by me). 3)I need to construct new object from this string. In java it's done by