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 bethard
Recipients bethard, doughellmann, ted.turocy
Date 2010-08-01.16:46:21
SpamBayes Score 1.7953769e-06
Marked as misclassified No
Message-id <1280681184.32.0.841256652031.issue9444@psf.upfronthosting.co.za>
In-reply-to
Content
It is intentional that you have to specify both "/foo" and "+foo" if you want them to be aliases for the same argument. A common use case for prefix_chars is to define "+x" and "-x" options, which usually mean different things.

As far as the current issue, I believe the current behavior is buggy - an argument that you can never use is added to the parser automatically:

>>> parser = argparse.ArgumentParser(prefix_chars='+')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/bethard/Documents/projects/python/2.X/Lib/argparse.py", line 1569, in __init__
    help=_('show this help message and exit'))
  File "/Users/bethard/Documents/projects/python/2.X/Lib/argparse.py", line 1246, in add_argument
    kwargs = self._get_optional_kwargs(*args, **kwargs)
  File "/Users/bethard/Documents/projects/python/2.X/Lib/argparse.py", line 1369, in _get_optional_kwargs
    raise ValueError(msg % tup)
ValueError: invalid option string '-h': must start with a character '+'

Yes you could explicitly specify add_help=True, but I think using an appropriate prefix character is actually the right behavior.
History
Date User Action Args
2010-08-01 16:46:24bethardsetrecipients: + bethard, doughellmann, ted.turocy
2010-08-01 16:46:24bethardsetmessageid: <1280681184.32.0.841256652031.issue9444@psf.upfronthosting.co.za>
2010-08-01 16:46:22bethardlinkissue9444 messages
2010-08-01 16:46:21bethardcreate