I have some convenience python scripts in my path that I want to run by calling them directly, e.g. myscript.py argument1
. But the arguments won't show up in sys.argv
.
test.py
#!python3.5
import sys
print(sys.argv)
So when I call this little script directly I can not access the given argument via sys.argv
.
c:\Users\MrLeeh\bin>test.py hello
['C:\\Users\\MrLeeh\\bin\\test.py']
While when I call it explicitly with the python
command I can access my argument.
c:\Users\MrLeeh\bin>python test.py hello
['C:\\Users\\MrLeeh\\bin\\test.py', 'hello']
I ask myself what is the reason for this and how can I access the arguments when using a direct call. My python files are associated with py.exe
.