In windows 7, if a python (2.7.10) script has been associated with the Python interpreter and the extension has been registered in the PATHEXT (windows) list, then when you kick off a script, one can simply type:
MyPythonScript
instead of the traditional:
python MyPythonScript.py
Which is great - but it no longer (appears) to take command line arguments. For example, consider the two below examples of a script that takes command line arguments. First the traditional way:
>>>> python echo_input.py --help
usage: echo_input.py [-h] [-s SIMPLE_VALUE] [-c] [-t] [-f] [-a COLLECTION]
[-A] [-B] [--version]
optional arguments:
-h, --help show this help message and exit
-s SIMPLE_VALUE Store a simple value
-c Store a constant value
-t Set a switch to true
-f Set a switch to false
-a COLLECTION Add repeated values to a list
-A Add different values to list
-B Add different values to list
--version show program's version number and exit
works just fine, but if it is invoked the alternative way:
echo_input --help
simple_value = None
constant_value = None
boolean_switch = False
collection = []
const_collection = []
It appears to no longer recognizes the command line arguments. FYI: The above script (by default) prints out those 5 lines if the it is run w/out any parameters as shown below for contrast:
>python echo_input.py
simple_value = None
constant_value = None
boolean_switch = False
collection = []
const_collection = []
So it appears as though it has lost it's ability to take command line arguments such as a simple flag for help.
I'm stuck for both an answer to this and a work around and would greatly appreciate any suggestions or experience.
Thank you in advance for your time ... :-)
Sources of inspiration:
sys.argv.