run-time inclusion of files
Stephen Fairchild
somebody at somewhere.com
Sat Sep 5 19:23:09 EDT 2009
travis+ml-python at subspacefield.org wrote:
> I'm interested in three seperate problems:
>
> 1) being able to import a file that isn't in the standard module include
> path
sys.path.insert(0, "/path/to/module"
module = __import__("module")
del sys.path[0]
Ideally this goes into a function, possibly with os.path.split to break
apart absolute paths.
> 2) being able to import a file whose name is specified in a python string
sys = __import__("sys")
> 3) being able to reload the file if it changes on disk
sys = reload(sys) # sys must have been imported already
Maybe use in conjunction with python-inotify and or Gamin for change
detection.
--
Stephen Fairchild
More information about the Python-list
mailing list