Variable class instantiation
Steven D'Aprano
steve at REMOVE-THIS-cybersource.com.au
Fri Dec 11 06:40:14 EST 2009
On Fri, 11 Dec 2009 11:36:13 +0000, Sion Arrowsmith wrote:
> Steven D'Aprano <steve at REMOVE-THIS-cybersource.com.au> 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 __special names__ to
> a minimum.)
No, no reason at all. I just forgot about getttr.
--
Steven
More information about the Python-list
mailing list