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 monkeyman79
Recipients monkeyman79, paul.j3, r.david.murray, v+python
Date 2021-01-26.09:22:27
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1611652947.39.0.0205122048678.issue42973@roundup.psfhosted.org>
In-reply-to
Content
>> In the docs fruits example, though, I think the input and output are inconsistent: you have a brown banana reported as yellow?

Yeah, I noticed that and fixed already :)


I agree with your ideas. My goal was just to provide bare minimum that would allow users to implement this functionality on their own, but turning it into something useful out of the box sounds like a good idea.

There could be new predefined action, e.g. 'extend_with_capture' (or just 'extend_capture') which could be used like this:

  parser.add_argument('fruits', nargs='*', action='extend_capture', capture_once=['color'])

Where 'capture' would be one of: a list of parameters to capture (could be a string instead of a list if it's just one parameter) or '*' to capture all optional parameters and 'capture_once' would be similar list of parameters to capture and reset to default.

>> Does the namespace still contain the default value for an optional after it has been used?  It looks like it might

I think it does - not the namespace, but ArgumentParser, which is also available in Action.__call__, has 'get_defaults'.

>> I'm not sure how that plays with optionals that use append or append_const storage methods, nor do I fully understand the comment in "def _copy_items(items):"

I don't see any danger here, the action will just have to make sure to capture copy of the array, rather than reference to it. The same applies to 'extend'.
History
Date User Action Args
2021-01-26 09:22:27monkeyman79setrecipients: + monkeyman79, v+python, r.david.murray, paul.j3
2021-01-26 09:22:27monkeyman79setmessageid: <1611652947.39.0.0205122048678.issue42973@roundup.psfhosted.org>
2021-01-26 09:22:27monkeyman79linkissue42973 messages
2021-01-26 09:22:27monkeyman79create