New submission from Mike Hagerty:

Here's the relevant code:

opts, args = getopt.getopt(sys.argv[1:], "ih", ["help", "f1Hz","startdate=", 
"ndays="])

>main.py -i --f1H --startdat=2016-08-22 --ndays 2

Here's what getopt returns into opts:
opts= [('-i', ''), ('--f1Hz', ''), ('--startdate', '2016-08-22'), ('--ndays', 
'2')]

As you can see, I gave incomplete long_option names ("--f1H" instead of 
"--f1Hz",
"startdat" instead of "startdate") but getopt doesn't care.

getopt appears to scan just until the end of the input flag ("--f1H") and 
replaces this in opts with the full flag name passed to it ("--f1Hz") that 
matches the first characters.  

This means, for instance, you couldn't do:
>main.py --flag1=something --flag11=something_else

Surely this isn't intended behavior (?)

----------
messages: 276588
nosy: hager...@bc.edu
priority: normal
severity: normal
status: open
title: getopt.getopt error processing long_options
type: behavior
versions: Python 2.7

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue28171>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to