[issue26394] Have argparse provide ability to require a fallback value be present

2016-03-11 Thread Michael Herold
Michael Herold added the comment: Yes, a fallback hook at the end of parsing would have to be placed before the 'required' testing, not after as in my 'group' testing. Just to clarify: Would you suggest that a fallback call returns the parsed value (i.e. the fallback calls the action or alike

[issue26394] Have argparse provide ability to require a fallback value be present

2016-03-11 Thread Michael Herold
Michael Herold added the comment: Thanks so much for looking into my patch! Let me start by outlining that I don't understand how your alternate solutions are coping with the key problem. You are assuming that you get a populated Namespace object. However, `_parse_known_args` is exiting

[issue26394] Have argparse provide ability to require a fallback value be present

2016-03-02 Thread Michael Herold
Changes by Michael Herold <qua...@hemio.de>: Added file: http://bugs.python.org/file42062/example.py ___ Python tracker <rep...@bugs.python.org> <http://bugs.python

[issue26394] Have argparse provide ability to require a fallback value be present

2016-03-02 Thread Michael Herold
Michael Herold added the comment: I have prepared a working patch to sketch how this could be implemented. A small example (example.py) shows how this feature can be used to implement a fallback to environment variables. This patch allows Currying of positional arguments (i.e. you can give

[issue26394] Have argparse provide ability to require a fallback value be present

2016-02-21 Thread Michael Herold
Michael Herold added the comment: Thank you for clarifying my request. Callables sound like a great solution to me! Looks like the fallback should be called in `take_action()` if argument_values is "empty" (None?). Per default it should be transparent to an `Action` if the values

[issue26394] argparse: Add set_values() function to complement set_defaults()

2016-02-20 Thread Michael Herold
New submission from Michael Herold: argparse has at least three features to set defaults (default=, set_defaults(), argument_default=). However, there is no feature to set the values of arguments. The difference is, that a required argument has to be specified, also if a default value