Importing User-defined Modules
Thomas Guettler
guettli at thomas-guettler.de
Mon Jul 25 05:13:55 EDT 2005
Am Sun, 24 Jul 2005 13:12:04 -0400 schrieb Walter Brunswick:
> I need to import modules with user-defined file extensions that differ from '.py', and also (if possible) redirect the bytecode
> output of the file to a file of a user-defined extension.
> I've already read PEP 302 (http://www.python.org/peps/pep-0302.html), but I didn't fully understand it. Would someone [who
> understands it] please be able to give me a synopsis of it, along with a few explanatory examples, or some other alternatives, if
> any?
You could do it like this:
Copy the file to directory which is in sys.path. Give the file
the extension ".py". Import it with __import__
(http://docs.python.org/lib/built-in-funcs.html#l2h-6)
Copy the bytecode somewhere.
HTH,
Thomas
--
Thomas Güttler, http://www.thomas-guettler.de/
More information about the Python-list
mailing list