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.00:20:30
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1611620430.74.0.810245544638.issue42973@roundup.psfhosted.org>
In-reply-to
Content
>> Is it up to the special handler of the positional parameter to read and save the values of the optional parameters specified so far?

Yes, in order to get anything more that just concatenated list of positional parameters, one has to provide specialized action class. Basic functionality is easy to implement, as you can see in the fruits.py example.

>> ... how are you saving that context?

Entire context is stored in the namespace object. Action class has access to all previous parameters via the namespace and it can modify the namespace as needed. Standard 'store' action just adds value to the namespace, but specialized action can anything.

>> What about the ones unspecified so far?

They are obviously not available for the action processing positional parameters preceeding them, but will be present in the resulting namespace and can be processed after parsing is done.

>> Can one even read and save the default value?

I'm not sure what do you mean, but it all depend on how action class deals with it.

>> And where does it get stored? Is the value of the positional parameter turned into a dict or class containing its own value + the saved optional parameters?

It all gets stored in the namespace. Turning positionals + optionals into a dict or class seems most reasonable, but it all depends on how action class will deal with them.

>> I think I have seen Unix command line programs that had rich semantics similar to what you are proposing, where the sequence of repeated optional args could affect handling of later positionals but not earlier ones.

For example 'tar' with '-C' parameter which applies to all files following it.
History
Date User Action Args
2021-01-26 00:20:30monkeyman79setrecipients: + monkeyman79, v+python, r.david.murray, paul.j3
2021-01-26 00:20:30monkeyman79setmessageid: <1611620430.74.0.810245544638.issue42973@roundup.psfhosted.org>
2021-01-26 00:20:30monkeyman79linkissue42973 messages
2021-01-26 00:20:30monkeyman79create