We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
GitHub fields:
assignee = None closed_at = <Date 2015-07-03.14:33:46.094> created_at = <Date 2015-07-03.09:32:15.511> labels = ['invalid', 'type-bug', 'library'] title = 'Getopt overwrites variables unexpectedly' updated_at = <Date 2015-07-03.14:33:46.092> user = 'https://bugs.python.org/Jak'
bugs.python.org fields:
activity = <Date 2015-07-03.14:33:46.092> actor = 'r.david.murray' assignee = 'none' closed = True closed_date = <Date 2015-07-03.14:33:46.094> closer = 'r.david.murray' components = ['Library (Lib)'] creation = <Date 2015-07-03.09:32:15.511> creator = 'Jak' dependencies = [] files = [] hgrepos = [] issue_num = 24556 keywords = [] message_count = 2.0 messages = ['246153', '246181'] nosy_count = 2.0 nosy_names = ['r.david.murray', 'Jak'] pr_nums = [] priority = 'normal' resolution = 'not a bug' stage = 'resolved' status = 'closed' superseder = None type = 'behavior' url = 'https://bugs.python.org/issue24556' versions = ['Python 2.7', 'Python 3.4']
The text was updated successfully, but these errors were encountered:
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.
Sorry, something went wrong.
This behavior is correct:
rdmurray@session:~>getopt a:b:c -a value1 -b value2 -cbanana -a value1 -b value2 -c -b anana --
No branches or pull requests
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: