On Thu, Apr 30, 2009 at 04:33:57AM -0300, Gabriel Genellina wrote:
> En Thu, 30 Apr 2009 03:04:40 -0300, alex23 <wuwe...@gmail.com> escribió:
>> Are you familiar with __import__?
>>
>> iotypes = ["WINGTL","VLMPC","VLM4997"]
>> for iotype in iotypes:
>>   packagename = "VLMLegacy." + iotype + ".Conditions"
>>   classname   = iotype + "_Conditions"
>>   module      = __import__(packagename)
>>   cls         = getattr(module, classname)
>>   # etc
>
> (doesn't work as written, because __import__ returns the top package when 
> given a dotted name)
> Replace the last three lines with:
>
>     __import__(packagename)
>     module = sys.modules[packagename]
>     cls = getattr(module, "Conditions")

Thanks. That works marvelously. I just knew there
had to be a better way.


Attachment: signature.asc
Description: Digital signature

--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to