windows - Python scripts enabled to run w/out the CLI do not take command line arguments -
in windows 7, if python (2.7.10) script has been associated python interpreter , extension has been registered in pathext (windows) list, when kick off script, 1 can type:
mypythonscript
instead of traditional:
python mypythonscript.py
which great - no longer (appears) take command line arguments. example, consider 2 below examples of script takes command line arguments. first 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 message , exit -s simple_value store simple value -c store constant value -t set switch true -f set switch false -a collection add repeated values list -a add different values list -b add different values list --version show program's version number , exit
works fine, if invoked alternative way:
echo_input --help simple_value = none constant_value = none boolean_switch = false collection = [] const_collection = []
it appears no longer recognizes command line arguments. fyi: above script (by default) prints out 5 lines if run w/out parameters shown below contrast:
>python echo_input.py simple_value = none constant_value = none boolean_switch = false collection = [] const_collection = []
so appears though has lost it's ability take command line arguments such simple flag help.
i'm stuck both answer , work around , appreciate suggestions or experience.
thank in advance time ... :-)
sources of inspiration:
does work (thanks @eryksun suggested fixes -- don't have windows machine more)?
c:\>ftype python.file="c:\python27\python.exe" "%1" %* c:\>assoc .py=python.file
this adds/modifies progid in hklm\software\classes
. depending on current configuration, may have select progid (python.file
) in explorer's "open with" dialog.
Comments
Post a Comment