how to import from variable source
Alex Martelli
aleaxit at yahoo.com
Sun Apr 15 05:08:00 EDT 2001
More information about the Python-list mailing list
Sun Apr 15 05:08:00 EDT 2001
- Previous message (by thread): how to import from variable source
- Next message (by thread): how to import from variable source
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
"Rob Brown-Bayliss" <rob at ZOOstation.cc> wrote in message news:mailman.987320124.14328.python-list at python.org... [snip] > module = 'mymod' > import module > > Only, as I found out I get an error stating that there is not module > called module. > > Is this possible in python? Is there a better way perhapse? Standard module imp provides functions find_module and load_module that support this. See: http://www.python.org/doc/current/lib/examples-imp.html for Python code that uses them to mimic the import statement (without hierarchical packages) and is easy to tweak so as to decouple the diskfile name from the name you want to use for the module in your code. Alex
- Previous message (by thread): how to import from variable source
- Next message (by thread): how to import from variable source
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list