| Store | Cart

name of this python program

From: Gandalf <gand...@geochemsource.com>
Wed, 10 Mar 2004 13:00:19 +0100
>>>hi there>>when i start a python script with >        python myprog.py >how can i find out the name of my script ("myprog.py") inside the script>itself. looking for something like args[0]...>>cheers, leo>  >
import sys
print sys.argv[0]

However, it can be wrong if you run it that way ('python myprog.py'). It 
works when you run it this way: 'myprog.py'.

Best,

G

Recent Messages in this Thread
leo Mar 10, 2004 11:17 am
Peter Maas Mar 10, 2004 11:28 am
Gandalf Mar 10, 2004 12:00 pm
Pete Shinners Mar 10, 2004 03:38 pm
Scott David Daniels Mar 10, 2004 06:11 pm
Peter Abel Mar 10, 2004 09:16 pm
Messages in this thread