argv[0] manipulation
P_spam_ at draigBrady.com
P_spam_ at draigBrady.com
Wed Dec 11 07:02:52 EST 2002
Hi,
I had the idea to select debugging mode
in my application depending on the contents of argv[0].
The logic was:
if '/' in argv[0]: #explicit path so debug
debugging = 1
else:
debugging = 0
However this fails in the case where you
invoke a script in the current directory
with the python interpreter explicitly.
So shouldn't python change argv[0] to
'./myscript' instead of 'myscript' in this case:
python myscript
Usually the current directory is not in the
$PATH for security reasons, so an argv of
'./myscript' is the equivalent of (what you
would need to type to run the script) python myscript.
I don't see this causing a problem (even on
windows ?(which I know nothing about BTW)).
thanks,
Pádraig.
More information about the Python-list
mailing list