[Tutor] Using __import__ and byte-compiling
Tim Johnson
tim at johnsons-web.com
Tue Feb 6 17:05:58 CET 2007
I should add one thing: If the source module is in the same directory,
it *is* byte-compiled.
thanks
tim
On Tuesday 06 February 2007 03:46 pm, Tim Johnson wrote:
> 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