Directory of python

Jürgen Hermann jhe at webde-ag.de
Fri Jul 28 06:03:57 EDT 2000


<pauljolly at my-deja.com> schrieb im Newsbeitrag
news:8lre6p$140$1 at nnrp1.deja.com...
> Running Python under NT and UNIX systems. Writing a python script that
> can be run by typing at the command prompt (or similar) by virtue of
> the fact that the python program directory has been added to path.

[d:\python]cat mypath.py
print __file__

[c:\]python -c "import mypath"
D:\Python\mypath.py

When you add the second command to a batch file, you have what you want.
Unix is similar (shell script there).

To get the directory, use os.path.split(__file__).





More information about the Python-list mailing list