Python Language sys.argv[0] is the name of the file being executed


Example

The first element of sys.argv[0] is the name of the python file being executed. The remaining elements are the script arguments.

# script.py
import sys

print(sys.argv[0])
print(sys.argv)

$ python script.py
=> script.py
=> ['script.py']

$ python script.py fizz
=> script.py
=> ['script.py', 'fizz']

$ python script.py fizz buzz
=> script.py
=> ['script.py', 'fizz', 'buzz']