name of this python program

Peter Maas fpetermaas at
Wed Mar 10 12:28:38 CET 2004

leo schrieb:
> when i start a python script with 
>         python 
> how can i find out the name of my script ("") inside the script
> itself. looking for something like args[0]...

import sys
import os
print sys.argv[0]
print os.path.basename(sys.argv[0])

Mit freundlichen Gruessen,

Peter Maas

Peter Maas, M+R Infosysteme, D-52070 Aachen, Hubert-Wienen-Str. 24
Tel +49-241-93878-0 Fax +49-241-93878-20 eMail peter.maas at

More information about the Python-list mailing list