Movatterモバイル変換


[0]ホーム

URL:


homepage

Issue32027

This issue trackerhas been migrated toGitHub, and is currentlyread-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title:argparse allow_abbrev option also controls short flag combinations
Type:behaviorStage:resolved
Components:Documentation, Library (Lib)Versions:Python 3.7, Python 3.6
process
Status:closedResolution:duplicate
Dependencies:Superseder: argparse: allow_abbrev=False stops -vv from working
View:26967
Assigned To: docs@pythonNosy List: berker.peksag, docs@python, joern, paul.j3
Priority:normalKeywords:patch

Created on2017-11-14 17:29 byjoern, last changed2022-04-11 14:58 byadmin. This issue is nowclosed.

Pull Requests
URLStatusLinkedEdit
PR 4396closedjoern,2017-11-14 18:04
Messages (3)
msg306229 -(view)Author: Jörn Hees (joern)*Date: 2017-11-14 17:29
The allow_abbrev option (default True) currently is documented like this (https://docs.python.org/3/library/argparse.html#allow-abbrev):> Normally, when you pass an argument list to the parse_args() method of an ArgumentParser, it recognizes abbreviations of long options.However, it also controls combinations of short options and especially the combination of flags (store_const) like `-a -b` as `-ab`.Example snippet for testing:import argparseimport sysparser = argparse.ArgumentParser(    allow_abbrev=False)parser.add_argument('-a', action='store_true')parser.add_argument('-b', action='store_true')parser.add_argument('x', nargs='*')parser.parse_args('-a -b foo bar'.split())parser.parse_args('-ab foo bar'.split())As you can see the 2nd parse will fail if allow_abbrev=False.This issue is either a doc issue only or an unintended combination of long option shortening and (the way more common) flag combinations. When i deactivated this in my code, i wanted to disable the (nice to have) long option shortening, but i unintentionally also deactivated (MUST have) short flag combinations.
msg306343 -(view)Author: Berker Peksag (berker.peksag)*(Python committer)Date: 2017-11-16 08:01
Thank you for the report and for the PR. I think this is a duplicate ofissue 26967.> This issue is either a doc issue only or an unintended combination of> long option shortening and (the way more common) flag combinations.This is indeed a bug so it would be better to fix it.
msg324976 -(view)Author: paul j3 (paul.j3)*(Python triager)Date: 2018-09-11 01:47
ThePR 4396 should be closed.
History
DateUserActionArgs
2022-04-11 14:58:54adminsetgithub: 76208
2018-09-11 01:47:50paul.j3setnosy: +paul.j3
messages: +msg324976
2017-11-16 08:01:13berker.peksagsetstatus: open -> closed

superseder:argparse: allow_abbrev=False stops -vv from working
nosy: +berker.peksag
versions: - Python 3.5, Python 3.8
messages: +msg306343

type: behavior
resolution: duplicate
stage: patch review -> resolved
2017-11-14 18:04:46joernsetkeywords: +patch
stage: patch review
pull_requests: +pull_request4344
2017-11-14 17:29:42joerncreate
Supported byThe Python Software Foundation,
Powered byRoundup
Copyright © 1990-2022,Python Software Foundation
Legal Statements

[8]ページ先頭

©2009-2026 Movatter.jp