OK, I found three similar threads but all of them dealt with command-line arguments in C#. My question is, how can I read the command-line arguments from the cmd window, into IronPython?
The way I read Section 2.1.1 in these docs, it should work the same as CPython -- just import the sys module and get the values from the sys.argv array. It doesn't. Here's the test code I tried (file z.py):
import sys
print sys.argv[0]
print sys.argv[1]
When I call this as z.py testing using the CPython (2.7.4) interpreter, I get what you'd expect:
E:\>c:\python27\python.exe z.py testing
z.py
testing
E:\>
But when I call it using the IronPython (2.7.3) interpreter, I get:
Traceback (most recent call last):
File "E:\z.py", line 3, in <module>
IndexError: index out of range: 1
If I comment out line 3 and try again with IronPython, it runs fine:
E:\>z.py testing
E:\z.py
E:\>
So sys.argv[0] is being assigned but that's it -- the command-line arguments never appear as additional elements in sys.argv.
So either there's some extra step I'm missing, or sys.argv just doesn't work for this purpose in IronPython. Either way, how do I get the module to recognize the arguments?