ASPN ActiveState Programmer Network
ActiveState
/ Home / Perl / PHP / Python / Tcl / XSLT /
/ Safari / My ASPN /
Cookbooks | Documentation | Mailing Lists | Modules | News Feeds | Products | User Groups


Recent Messages
List Archives
About the List
List Leaders
Subscription Options

View Subscriptions
Help

View by Topic
ActiveState
.NET Framework
Open Source
Perl
PHP
Python
Tcl
Web Services
XML & XSLT

View by Category
Database
General
SOAP
System Administration
Tools
User Interfaces
Web Programming
XML Programming


MyASPN >> Mail Archive >> Jython-users
Jython-users
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

Privacy Policy | Email Opt-out | Feedback | Syndication
© ActiveState Software Inc. All rights reserved