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.py The name of the file is:./foo.py -- http://mail.python.org/mailman/listinfo/python-list