[Jython] current directory function and importing PY files?
Robert Oschler
Oschler at earthlink.net
Thu Nov 7 14:47:05 EST 2002
I have a JavaBean that is run by a foreign app, that loads and executes my
bean through a copy of the JVM the foreign app starts up. I want to be able
to import a Python module, residing in a *.py file, from an instance of
PythonInterpreter (and later from compiled Jython classes). How can I:
- get a listing of the current directory
- import the py file from the desired directory
Is this functionality is not allowed by the JVM's security policy (can I
change that?). If not, can I instead import a py file embedded in the JAR
that contains my JavaBean? If so, what Jython command do I use to do that?
If it's through a URL where can I find the correct syntax?
Or other options? I'm guessing there must be a solution here or the "import"
command would be useless for anything but importing java classes and
precompiled Jython classes. What's strange is, when I try exec'ing "import
os", it works without complaint. But when I try a common function, for
example "print(os.curdir), I get an error saying "org.python.modules.os" has
no attribute "curdir".
thx
More information about the Python-list
mailing list