argv[0] and __file__ inconsistency
John Machin
sjmachin at lexicon.net
Mon Dec 31 18:04:31 EST 2007
On Jan 1, 9:31 am, Hai Vu <wuh... at gmail.com> wrote:
> I currently use ActivePython 2.5.1. Consider the following code which
> I saved as cmdline.py:
> import sys
> print sys.argv[0]
> If I invoke this code as 'python cmdline.py', then the output is:
> cmdline.py
> If I invoke it as 'cmdline.py', then the output is:
> C:\Users\hai\src\python\cmdline.py
>
> The same happens for __file__. My question: do you have any
> suggestions for a more consistent way to figure out the full path of
> your script?
use os.path.abspath
More information about the Python-list
mailing list