sys.argv0 is the name of the file being executed

suggest change

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']

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents