PEP 736: Shorthand syntax for keyword arguments at invocation

I don’t want to restart any debate on the proposed syntax, only note that the lone keyword-based syntax that appeared in the poll (f(pass x)) isn’t mentioned in the “Rejected Ideas” section.

Also, the “Prior Art” section could make note of its similar use in Nix when defining an attribute set, alluded to in a November post (Syntactic sugar to encourage use of named arguments - #129 by emanueljg). Something like

In Nix, {inherit x; y=3} is shorthand for {x=x; y=3}.


In Nix, multiple variables can be inherited with a single inherit declaration,

{inherit x y; z=5} == {x=x; y=y; z=5}

Something similar in Python might look like f(inherit x y, z=5). There is a little more to the syntax in Nix, but any further mention here would start to look like advocacy for using it :slight_smile: . If any mention of the syntax is deemed useful for the PEP, I refer the editor to Language Constructs - Nix Reference Manual.

4 Likes