J
Jason Jiang
Hi,
How to get the name of the running .py file like the macro _FILE_ in C?
Thanks.
Jason
How to get the name of the running .py file like the macro _FILE_ in C?
Thanks.
Jason
import osJason said:Hi,
How to get the name of the running .py file like the macro _FILE_ in C?
Thanks.
Jason
Larry said:import osJason said:Hi,
How to get the name of the running .py file like the macro _FILE_ in C?
Thanks.
Jason
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
Simon Forman said:Larry said:import osJason said:Hi,
How to get the name of the running .py file like the macro _FILE_ in C?
Thanks.
Jason
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
Also, check out:
http://groups.google.ca/group/comp.lang.python/browse_frm/thread/712572b3c2f2cb13
Peace,
~Simon
Jason said:Hi,
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])
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.