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

This seems to be a very common idea to make python better, as I suggested something essentially the same here: Syntactic sugar to encourage use of named arguments

Only minor caveat was that I propose making the syntax more consistent with python’s long-standing *args and **kwargs syntax (established pythonic style), i.e.

my_function(=my_first_variable, =my_second_variable, =my_third_variable)

I listed the benefits as:

  • Encourages use of named variables, thereby increasing readability (explicit is better than implicit) and reducing bugs from argument transposition
  • Reduces verbosity (readability counts)
  • Encourages authors to use the same variable name when calling a function as the argument (increases consistency of variable names used, thereby increasing readability)
  • Reminiscent of python’s long-standing *args and **kwargs syntax (established pythonic style)
  • Reminiscent of python’s existing f-string debug f'{var=}' syntax (established pythonic style) and with a very similar function
  • This should be relatively easy to implement as it is simple syntactic sugar (if the implementation is easy to explain, it may be a good idea)
  • Backwards compatibility: this change is fully backwards compatible since the proposed syntax would raise a syntax error in current python versions

I think some confusion may be caused by the OP’s suggestion to automatically expand arguments without any change in syntax. I’d oppose that for the reasons as listed, but I think these issues are entirely ameliorated by the proposed = syntax:

  • the changes are entirely local at the call site f(=a) is immediately expanded into f(a=a)
  • there is no confusion about how to match variables to arguments (at least, none more than existing function call syntax)
  • it does not require looking at the function called