On Fri, 11 Dec 2009 11:36:13 +, Sion Arrowsmith wrote:
> Steven D'Aprano wrote:
>>thisModule = __import__(__name__)
>>classToUse = thisModule.__dict__['C1']
>
> Any reason to prefer this over:
>
> classToUse = getattr(thisModule, 'C1')
>
> ? (I think, for a module, they should do exactly
Steven D'Aprano wrote:
>thisModule = __import__(__name__)
>classToUse = thisModule.__dict__['C1']
Any reason to prefer this over:
classToUse = getattr(thisModule, 'C1')
? (I think, for a module, they should do exactly the same thing.
Personally, I prefer keeping explicit references to __specia
On 12/11/2009 8:26 PM, Jan Mach wrote:
Hi everybody,
I am currently solving the following problem and I am stuck. I am trying
to create instance of the class of variable name. I know, that the
following works:
if (something):
classToUse = C1
else:
classToUse = C2
o = classToUse()
,bu
On Fri, 11 Dec 2009 10:26:49 +0100, Jan Mach wrote:
> I need to have the class name in the
> string and then instantiate it:
>
> (this does not work of course)
> classToUse = "C1"
> o = classToUse()
>
> It is because I don`t know at the moment what the name of the class will
> be, I will load it
On Dec 11, 9:26 am, Jan Mach wrote:
> Hi everybody,
> I am currently solving the following problem and I am stuck. I am trying
> to create instance of the class of variable name. I know, that the
> following works:
>
> if (something):
> classToUse = C1
> else:
> classToUse = C2
>
> o = cla
Hi everybody,
I am currently solving the following problem and I am stuck. I am trying
to create instance of the class of variable name. I know, that the
following works:
if (something):
classToUse = C1
else:
classToUse = C2
o = classToUse()
,but this is not what I want. I need to have t