Grant Edwards <[EMAIL PROTECTED]> writes: > On 2005-05-11, jeff elkins <[EMAIL PROTECTED]> wrote: > >> I'm totally new to Python (obvious,yes?) so how might argv[0] fail? > > argv[0] contains whatever is put there by the program that > exec'ed you, and can therefore contain just about anything (or > nothing). It may not contain a full path, and your program's > install directory may not be in your $PATH (it be executed by a > shortcut or symlink).
That's true for the C-level, i.e. main's argv. If you're only concerned about CPython and the program is a script living in a file, then sys.argv[0] is the filename the python interpreter itself used to read the script. Hence it's a valid filename that refers to the script. It may be a relative filename, of course, in which case it won't be correct anymore if the program changes its working directory. Bernhard -- Intevation GmbH http://intevation.de/ Skencil http://skencil.org/ Thuban http://thuban.intevation.org/ -- http://mail.python.org/mailman/listinfo/python-list