On Mon, Aug 1, 2011 at 1:38 PM, happykid <psyking...@gmail.com> wrote:

> I want to use this function to get the directory path of the running
> script, but it always returns empty string. Can anyone help me solve
> this? Thank you.
> --
>

sys.argv[0] is the name of the script you called. If you call "python
spam.py", sys.argv[0] will be spam.py. Not /full/path/spam.py. Just spam.py.
And the directory part of "spam.py" is "". You'll have to call
os.path.abspath(sys.argv[0]) to get the full path, then get dirname.
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to