This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author joern
Recipients docs@python, joern
Date 2017-11-14.17:29:42
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1510680582.36.0.213398074469.issue32027@psf.upfronthosting.co.za>
In-reply-to
Content
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 argparse
import sys

parser = 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.
History
Date User Action Args
2017-11-14 17:29:42joernsetrecipients: + joern, docs@python
2017-11-14 17:29:42joernsetmessageid: <1510680582.36.0.213398074469.issue32027@psf.upfronthosting.co.za>
2017-11-14 17:29:42joernlinkissue32027 messages
2017-11-14 17:29:42joerncreate