[Tutor] Using __import__ and byte-compiling
Tim Johnson
tim at johnsons-web.com
Tue Feb 6 16:46:43 CET 2007
I am currently using the __import__ function to do
conditional importing of modules, whose names are determined
at runtime.
It appears the __import__ does not handle byte-compiling,
or at least it is not being done in my current implementation. From reading
the __import__ documentation, I don't see any options that handle
byte-compiles implicitly.
It follows then that I might want to use the py_compile module
with the follow method: (pseudo code example follows)
## ====================================
if exists module.pyc and
(timestamp for module.pyc) < (timestamp for module.py)
then compile module.py
else ## module.pyc does not exist
compile module.py
## ====================================
Or is there a python asset that handles this?
cheers
tim
--
Tim Johnson <tim at johnsons-web.com>
More information about the Tutor
mailing list