Re: how to get file name of the running .py file

2006-08-23 Thread Fredrik Lundh
Larry Bates wrote: >> How to get the name of the running .py file like the macro _FILE_ in C? > import os > import sys > print sys.argv[0] > > or if you just want the script and not the full path > > print os.path.basename(sys.argv[0]) except that __FILE__ is the name of the current source fil

Re: how to get file name of the running .py file

2006-08-23 Thread Bill Pursell
Jason Jiang wrote: > Hi, > > How to get the name of the running .py file like the macro _FILE_ in C? There are many ways--IMO the easiest is with __file__: >>> print __file__ /home/bill/.pystart >>> [tmp]$ cat foo.py #!/usr/bin/env python print "The name of the file is:%s"%__file__ [tmp]$ ./foo

Re: how to get file name of the running .py file

2006-08-23 Thread Jason Jiang
Thank you guys. Jason "Simon Forman" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Larry Bates wrote: >> Jason Jiang wrote: >> > Hi, >> > >> > How to get the name of the running .py file like the macro _FILE_ in C? >> > >> > Thanks. >> > Jason >> > >> > >> > >> import os >> impor

Re: how to get file name of the running .py file

2006-08-23 Thread Simon Forman
Larry Bates wrote: > Jason Jiang wrote: > > Hi, > > > > How to get the name of the running .py file like the macro _FILE_ in C? > > > > Thanks. > > Jason > > > > > > > import os > import sys > print sys.argv[0] > > or if you just want the script and not the full path > > print os.path.basename(sys.

Re: how to get file name of the running .py file

2006-08-23 Thread Larry Bates
Jason Jiang wrote: > Hi, > > How to get the name of the running .py file like the macro _FILE_ in C? > > Thanks. > Jason > > > import os import sys print sys.argv[0] or if you just want the script and not the full path print os.path.basename(sys.argv[0]) -Larry Bates -- http://mail.python

how to get file name of the running .py file

2006-08-23 Thread Jason Jiang
Hi, How to get the name of the running .py file like the macro _FILE_ in C? Thanks. Jason -- http://mail.python.org/mailman/listinfo/python-list