Steven Bethard <[email protected]> added the comment:
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.
----------
_______________________________________
Python tracker <[email protected]>
<http://bugs.python.org/issue9444>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com