[issue34235] PyArg_ParseTupleAndKeywords: support required keyword arguments

Tal Einat report at bugs.python.org
Sat Jun 8 14:34:20 EDT 2019


Tal Einat <taleinat at gmail.com> added the comment:

How about allowing '|' to be used again after '$'? Keyword arguments would be optional by default, but if there is a '|' after the '$', then those before it are required.

Examples:
"O|O$O|O" -- one required keyword arg and one optional one.
"O|O$OO" -- both keyword args are optional.
"O|O$|OO" -- both keyword args are optional.
"O|O$OO|" -- both keyword args are required.

Pros:
1. Backwards-compatible with current notation.
2. No additional characters used as sigils.
3. Similar meaning as existing use of '|' to separate required and optional args.
4. Same order as for Python function.

Cons:
1. Need to scan to the end of the format string to figure out whether keyword args are optional or required.

----------
nosy: +taleinat

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue34235>
_______________________________________


More information about the Python-bugs-list mailing list