New submission from Jak: The getopt library has, what I assume is, some unexpected behaviour when adding extra text to command line parameter that getopt expects as a flag.
Using input parameters a, b and c as an example below, where a and b both take values and c is a flag. Example code: options, remainders = getopt.getopt(sys.argv[1:], "a:b:c") Normal output is given when you supply sensible values for a, b and c: Input: -a value1 -b value2 -c Output: [('-a', 'value1'), ('-b', 'value2'), ('-c', '')] Unexpected output happens when you give extra text after the '-c' that begins with a letter matching that of a previous parameter: Input -a value1 -b value2 -cbanana Output: [('-a', 'value1'), ('-b', 'value2'), ('-c', ''), ('-b', 'anana')] Looping through the output variables, as most example programs do, results in the value for '-b' being over-written. ---------- components: Library (Lib) messages: 246153 nosy: Jak priority: normal severity: normal status: open title: Getopt overwrites variables unexpectedly type: behavior versions: Python 2.7, Python 3.4 _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue24556> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com