from (some module) import *
Marc Christiansen
tolot at utolot.toppoint.de
Wed Oct 27 23:51:06 EDT 1999
Ed elb at cfdrc.com wrote:
> I'm new to Python, I hope I'm not trying to do the wrong thing here, but
> pls correct me if I am:
>
> I want to prompt for a module name, then import it. How do I make the
> module name in the "from" or "import" operators a variable? I was
> trying
>
> print "enter the file name"
> filename = raw_input()
> from filename import *
try this: >>> exec "from "+filename+" import *"
exec-can-be-usefull-ly y'rs Marc
--
"Claims about the evils of cannabis have been exaggerated: The question now
is not whether it should be legalised, but how and when."
http://www.newscientist.com/ns/980221/contents.html
PGP-Key fingerprint EE 2E C1 06 D1 28 89 D2 F9 CE 35 7B F8 F4 42 52
More information about the Python-list
mailing list