import unknown module name

Andrew Dalke adalke at mindspring.com
Fri Jan 10 07:40:43 EST 2003


Me:
 >>  You'll need to do
>>
>>   codepage = getattar(__import__(pagename), "oldpage")

err, must learn not to post while watching TV

codepage = getattar(__import__(pagename), oldpage)

> Doesn't
> 
>       codepage = sys.modules[pagename]
> 
> also work? At least no loop needed...

Err, umm, yes?

*thinking for an excuse*

Ahh, but if you didn't know/care if the object requested
was a module or a class, then it wouldn't work, which
was my case.

*whew*

					Andrew
					dalke at dalkescientific.com





More information about the Python-list mailing list