from spam import eggs, spam at runtime, how?

Rene Pijlman reply.in.the.newsgroup at my.address.is.invalid
Mon Dec 8 13:11:51 EST 2003


Fredrik Lundh:
>Rene Pijlman:
>> But it works like this:
>>
>>   spam = __import__('spam',globals(),locals(),['eggs'])
>>   eggs = spam.eggs
>
>or:
>
>    spam = __import__('spam.eggs')
>    eggs = spam.eggs

Yes, and a bit more elegant (pythonic?). Thanks.

-- 
René Pijlman




More information about the Python-list mailing list