Re: [Jython-users] Statement execfile()
by Oti other posts by this author
Mar 24 2004 10:12PM messages near this date
[Jython-users] Statement execfile()
|
[Jython-users] Command execfile("myfile.py")
[ Bruno Chauchaix ]
> I'm working in window environment, and with the Jython interpreter I
> use
> the execfile("myfile.py"). It works only if I use an absolute path
> for
> "myfile.py". How can I run "myfile.py" from everywhere wihout the
> absolute path? I tried to modify python.path in the registry without
> success? Thanks for your help
Bruno,
one possibility is to use import. Given a directory adir on sys.path
(python.path), and if you have the following files:
adir/mod1/__init__.py (can be empty)
adir/mod1/mod2__init__.py (can be empty)
adir/mod1/mod2/myfile.py
you can use:
> >> import mod1.mod2.myfile
or:
> >> from mod1.mod2.myfile import aClass
This is not exactly the same like execfile(), but certainly useful if
myfile.py does not change.
Best wishes,
Oti.
-------------------------------------------------------
This SF.Net email is sponsored by: IBM Linux Tutorials
Free Linux tutorial presented by Daniel Robbins, President and CEO of
GenToo technologies. Learn everything from fundamentals to system
administration.http://ads.osdn.com/?ad_id=1470&alloc_id=3638&op=click
_______________________________________________
Jython-users mailing list
Jython-users@[...].net
https://lists.sourceforge.net/lists/listinfo/jython-users
Thread:
Bruno Chauchaix
Oti
|