Name of the Script
David Given
dg at pearl.tao.co.uk
Mon Mar 5 12:22:38 EST 2001
In article <NJCo6.6720$qv3.2834377 at nnrp5-w.sbc.net>,
"Alex Shindich" <alex at shindich.com> writes:
> try the following:
>
> import sys
> print sys.argv[0]
> ....
> The first argument in the argument list is the name of the script that got
> invoked.
Note that it's not always accurate on Unix systems. There are a number of
ways scripts can be invoked, only some of which pass the name of the file
in argv[0]. (This is the same as a the generic Unix question: `How do I
find out where my executable lives?' It's basically not solveable.) I
don't know about Windows, though.
--
+- David Given ---------------McQ-+ "Opportunity is missed by most people
| Work: dg at tao-group.com | because it's dressed in overalls and looks
| Play: dgiven at iname.com | like work." --- Thomas Edison
+- http://wired.st-and.ac.uk/~dg -+
More information about the Python-list
mailing list