bukzor wrote:
I have to go into these convulsions to get the directory that the
script is in whenever I need to use relative paths. I was wondering if
you guys have a better way:
...
If you just need the current path (where it is executed) why not use os.getcwd()
which returns a string of the absolute path to the module being executed.


$ echo "print __file__" > path.py
$ ipython
In [1]: import path
path.pyc

In [2]: import os

In [3]: os.path.join(os.getcwd(), path.__file__.rstrip("c"))
Out[3]: '/home/andrew/path.py'
--
Andrew
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to