overriding import
Michael Hudson
mwh21 at cam.ac.uk
Sat Jun 3 05:26:38 EDT 2000
"Rainer Deyke" <root at rainerdeyke.com> writes:
> I am writing a C++ program with embedded python. I want to redirect
> import commands to read the file from a different source, possibly
> not a true file at all but an entry in a zip file. How would I do
> this?
I don't know if being embedded offers other ways of doing this, but in
Python code (which should work here), you'd probably want to use
Greg Stein's imputil.py:
http://www.lyra.org/greg/python/
If you want to override *all* import unconditionally, you can assign
to __builtin__.__import__, but that requires a certain amount of
Python internals knowledge.
HTH,
Michael
--
please realize that the Common Lisp community is more than 40
years old. collectively, the community has already been where
every clueless newbie will be going for the next three years.
so relax, please. -- Erik Naggum, comp.lang.lisp
More information about the Python-list
mailing list