Re: Creating class instance from module and class name

2009-10-06 Thread Bruno Desthuilliers
gentlestone a écrit : (snip) one more question - __class__ is the way for getting the classname from the class instance - obj.__class__ is a reference to the class object itself, not it's name. how can I get the module name? module_obj.__name__ And while we're at it: obj.__class__.__modu

Re: Creating class instance from module and class name

2009-10-06 Thread Diez B. Roggisch
Steven D'Aprano schrieb: On Mon, 05 Oct 2009 23:32:27 -0700, gentlestone wrote: Suppose I've saved the class name and (don't know how) I've also saved the Class's module (package path or I don't know what's the name for XYZ "from X.Y.Z import ...). How can I construct a new class according to s

Re: Creating class instance from module and class name

2009-10-06 Thread Steven D'Aprano
On Tue, 06 Oct 2009 00:09:08 -0700, gentlestone wrote: > one more question - __class__ is the way for getting the classname from > the class instance - Not quite. __class__ returns the class object, not the name. Given the class object, you ask for __name__ to get the name it was defined as[1].

Re: Creating class instance from module and class name

2009-10-06 Thread Chris Rebert
On Tue, Oct 6, 2009 at 12:09 AM, gentlestone wrote: > On 6. Okt, 08:55 h., Steven D'Aprano > wrote: >> On Mon, 05 Oct 2009 23:32:27 -0700, gentlestone wrote: >> > Suppose I've saved the class name and (don't know how) I've also saved >> > the Class's module (package path or I don't know what's th

Re: Creating class instance from module and class name

2009-10-06 Thread gentlestone
On 6. Okt, 08:55 h., Steven D'Aprano wrote: > On Mon, 05 Oct 2009 23:32:27 -0700, gentlestone wrote: > > Suppose I've saved the class name and (don't know how) I've also saved > > the Class's module (package path or I don't know what's the name for XYZ > > "from X.Y.Z import ...). How can I constr

Re: Creating class instance from module and class name

2009-10-06 Thread Steven D'Aprano
On Mon, 05 Oct 2009 23:32:27 -0700, gentlestone wrote: > Suppose I've saved the class name and (don't know how) I've also saved > the Class's module (package path or I don't know what's the name for XYZ > "from X.Y.Z import ...). How can I construct a new class according to > saved informations? I

Creating class instance from module and class name

2009-10-05 Thread gentlestone
Suppose I've saved the class name and (don't know how) I've also saved the Class's module (package path or I don't know what's the name for XYZ "from X.Y.Z import ...). How can I construct a new class according to saved informations? If I don't know what Class it could be, only I have the saved Cla