paul j3 added the comment: A related issue is
http://bugs.python.org/issue24754 argparse add_argument with action="store_true", type=bool should not crash In this case the user specified a parameter that the 'store_true' subclass did not accept. In both cases, 'parser.add_argument' does minimal error checking (or catching), so the user ends up seeing the '__init__' argument error. This line in the 'store_const' documentation is clearly wrong. There's no default. (Note that the const keyword argument defaults to the rather unhelpful None.) Possible fixes to the bigger issue: - major addition to the documentation, documenting allowable subclass parameters (but the subclasses aren't part of the API). - major addition to add_argument that filters parameters before passing them to the subclasses. But can that be done without replicating information that is implicit in the subclass __init__? Can we use advanced inspection? What about user defined Action classes? - minor addition to add_argument that catches the __init__ parameter errors and adds a mollifing explanation. - somehow make Action (and its subclasses) responsible for a nice error message. But how do you override the normal behavior of Python regarding function parameters? ---------- nosy: +paul.j3 _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue25299> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com