SubniC SubniC - 3 months ago 12x
Python Question

Get the name of current script with Python

I'm trying to get the name of the Python script that is currently running.

For example, I have a script called
and I would like to do something like this inside it:

print Scriptname

and get:


Use __file__. If you want to omit the directory part (which might be present), you can use import os,os.path.basename(__file__).