Message 276588 - Python tracker (original) (raw)
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 (?)