Allow identifiers as keyword arguments at function call site (extension of PEP 3102?)

@elis.byberi What I’ve suggested is not that you make variable names visible to other functions. It’s that you can pass on explicitly copying code when calling other functions. That’s all – no more than that. What I’m suggesting is not more “permissive” than passing on **kwargs which is totally acceptable and used all around (namely decorators and wrappers). I would go as far as to say that whenever a language offers keyword arguments, it should offer this feature.

Yes, it has wide-spread real-world usage. In the Python library itself I found over 4,000 non-singular uses (meaning the library didn’t use this style of assignment only once, but at least 4 times). About half were under Lib/test. But that leaves the other half elsewhere. Here’s a nice plot. I split them into var assignments (a-la dict(a=a)) and attr assignments (a-la dict(a=x.a)).

(I used AST to so this. You can also play around with the code I used to make this)

It’s also very, very widespread in Javascript, which is a very widespread language on its own.

2 Likes