Importing a module without creating a .pyc/.pyo file?
thomas.heller at ion-tof.com
Fri Jan 25 13:25:21 CET 2002
"Michael Hudson" <mwh at python.net> wrote in message news:u665qhehc.fsf at python.net...
> "Thomas Heller" <thomas.heller at ion-tof.com> writes:
> > Is it possible to import a module xxx.py without compiling it
> > (implicitely) to .pyo/.pyc, or do I always have to delete the
> > compiled file afterwards if it gets in the way?
> Like Alex said, you could use imp, or you could just do it by hand
> newm = new.module(name)
> sys.modules[name] = newm
> newm.__file__ = filepath
> exec compile(open(filepath).read(), filepath, "exec") in \
> comes fairly close, I think.
Bingo! Alex was close, but you seem to have read my mind.
Thanks to you both,
More information about the Python-list