Message252106
Python 2.7.3 (default, Dec 18 2014, 19:10:20)
[GCC 4.6.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from argparse import ArgumentParser
>>> parser = ArgumentParser()
>>> parser.add_argument("--foo", help="foo", action='store_const')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python2.7/argparse.py", line 1281, in add_argument
action = action_class(**kwargs)
TypeError: __init__() takes at least 4 arguments (4 given)
>>>
First, the exception message is entirely unhelpful (you wanted at least 4, you got 4, what's your problem?)
Second, adding "const=None" to the invocation makes it succeed; but, according to https://docs.python.org/2/library/argparse.html#const this argument defaults to "None", so it shouldn't be necessary to specify it explicitly. Thus, either the documentation or the implementation is wrong. |
|
Date |
User |
Action |
Args |
2015-10-02 11:25:46 | A. Skrobov | set | recipients:
+ A. Skrobov, docs@python |
2015-10-02 11:25:46 | A. Skrobov | set | messageid: <1443785146.27.0.85852377889.issue25299@psf.upfronthosting.co.za> |
2015-10-02 11:25:46 | A. Skrobov | link | issue25299 messages |
2015-10-02 11:25:45 | A. Skrobov | create | |
|