faqts : Computers : Programming : Languages : Python : Common Problems

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

28 of 34 people (82%) answered Yes
Recently 5 of 10 people (50%) answered Yes

Entry

How do I find out the name of my script?
What is my script's name?

Mar 9th, 2000 19:40
Steve Holden,


#!/usr/bin/python
import sys
print "Script name is", sys.argv[0]
Note that the value returned may well have path information
in it, which you can remove using the os.path.basename()
function.  os.path.split() will give you both the path (if
any) AND the script name.