3

I've noticed a somewhat strange behavior when running a python script on Windows with and without the word "python".

My script:
print "Command line arguments:", sys.argv
print "Command line arguments length", len(sys.argv)

When I run try.py 1 2 3 4 I get:
Command line arguments: ['C:\\PythonTemp\\try.py']
Command line arguments length 1

Which is obviously wrong...

But when I run python try.py 1 2 3 4 I get the expected result:
Command line arguments: ['try.py', '1', '2', '3', '4']
Command line arguments length 5

Can you please explain why this happens?

Augustina
  • 259
  • 1
  • 4
  • 15

0 Answers0