Text of peps.python.org › pep-0736 as Styx crawled it on Oct 13, 2026. The page may have changed since. Only its words are kept, without pictures or layout, and only the first part of a long page.

Open the live page

PEP 736 – Shorthand syntax for keyword arguments at invocation | peps.python.org

PEP 736 – Shorthand syntax for keyword arguments at invocation PEP 736 – Shorthand syntax for keyword arguments at invocation Author : Joshua Bambrick <jbambrick at google.com>, Chris Angelico <rosuav at gmail.com> Discussions-To : Discourse thread Status : Rejected Type : Standards Track Created : 28-Nov-2023 Python-Version : 3.14 Post-History : 14-Oct-2023 , 17-Jan-2024 , 17-Jul-2024 Resolution : 13-Mar-2025 Table of Contents Abstract Motivation Rationale Encourages use of named arguments Reduces verbosity Encourages consistent variable names Highlights arguments not following this pattern Applicability to dictionary construction Specification Backwards Compatibility Security Implications Prior Art Applicability Proposed Syntax How to Teach This Rejected Ideas f(a, b, *, x) f(=x) f(%x) or f(:x) or f(.x) Objections The syntax is ugly The feature is confusing The feature is not explicit The feature adds another way of doing things Renaming the variable in the calling context will break the code This syntax increases coupling Recommendations for Using This Syntax Impact on Editing Using a plain text editor Proposals for IDEs Highlighting NameErrors Jump to definition Highlighting other references Rename symbol Reference Implementation References Copyright Abstract This PEP proposes to introduce syntactic sugar f(x=) for the common pattern where a keyword argument has the same name as that of the variable corresponding to its value f(x=x) .

Motivation Keyword argument syntax can become needlessly repetitive and verbose. Consider the following call: my_function ( my_first_variable = my_first_variable , my_second_variable = my_second_variable , my_third_variable = my_third_variable , ) The case of a keyword argument name matching the variable name of its value is prevalent among Python libraries. This redundancy discourages use of named arguments and reduces readability by increasing visual noise.

Rationale There are two ways to invoke a function with arguments: by position and by keyword. By being explicit, keyword arguments increase readability and minimise the risk of inadvertent transposition. On the flipside, positional arguments are often preferred simply to minimise verbosity and visual noise. We contend that a simple syntactic sugar used to simplify this common pattern would confer numerous benefits: Encourages use of named arguments By reducing the visual noise that established keyword argument syntax can cause, this syntax would encourage the use of named arguments, thereby increasing readability and reducing bugs from argument transposition.

Reduces verbosity By minimising visual noise and in some cases lines of code, we can increase readability. Encourages consistent variable names A common problem is that semantically identical variables have different names depending on their contexts. This syntax would encourage authors to use the same variable name when calling a function as the argument name, which would increase consistency of variable names used and hence improve readability.

Highlights arguments not following this pattern With the current syntax, function calls where many arguments are forwarded from the local context can make other argument values easy to miss due to the visual noise. For example: add_middleware ( excluded_urls = excluded_urls , server_request = server_request , client_request = client_request , client_response = client_response , span_details = _get_span_details (), tracer = tracer , meter = meter , ) With this syntax, the exceptional arguments become easier to identify: add_middleware ( excluded_urls = , server_request = , client_request = , client_response = , span_details = _get_span_details (), tracer = , meter = , ) Applicability to dictionary construction This syntax can be applied to dictionary construction where a similar pattern frequently occurs (where dictionary keys are identical the names of the variables assigned as their values), {"x": x, "y": y} or dict(x=x, y=y) .

With this feature, this can now also be trivially written as dict(x=, y=) . Whether to further support similar syntax in dictionary literals is an open question beyond the scope of this PEP. Specification We propose to introduce syntactic sugar such that, if the value of a keyword argument is omitted from a function invocation, the argument’s value is inferred to be the variable matching that name at the invocation scope.

For example, the function invocation: my_function ( my_first_variable = , my_second_variable = , my_third_variable = ) Will be interpreted exactly equivalently to following in existing syntax: my_function ( my_first_variable = my_first_variable , my_second_variable = my_second_variable , my_third_variable = my_third_variable , ) If no variable matches that name in the invocation scope, a NameError is raised in an identical manner as would be with the established expanded syntax.

This proposal only pertains to function invocations; function definitions are unaffected by the syntax change. All existing valid syntax is unchanged. Backwards Compatibility Only new syntax is added which was previously syntactically erroneous. No existing valid syntax is modified. As such, the changes proposed are fully backwards compatible. Security Implications There are no security implications for this change. Prior Art Python already possesses a very similar feature in f-string interpolation where f'{x=}' is effectively expanded to f'x={x}' (see related GitHub issue ).

Several modern languages provide similar features during function invocation, sometimes referred to as ‘punning’. For example: In Ruby, f(x:, y:) is syntactic sugar for f(x: x, y: y) . See the Ruby 3.1.0 release notes (search for “keyword arguments”). In ReasonML, f(~x, ~y) is syntactic sugar for f(~x=x, ~y=y) . See the ReasonML function documentation (search for “punning”). In SystemVerilog, (.mult, .mop1, .data); is syntactic sugar for (.mult(mult), .mop1(mop1), .data(data)); .

See SystemVerilog Implicit Port Connections . In Jakt, f(x, y) is syntactic sugar for f(x: x, y: y) . See The Jakt programming language . Beyond function invocation specifically, more languages offer similar features: In OCaml, let+ x in … is syntactic sugar for let+ x = x in … . See OCaml: Short notation for variable bindings (let-punning) . In JavaScript, { x, y } is syntactic sugar for {x: x, y: y} . See JavaScript: Object Initializer .

In Rust, User { x, y } is shorthand for User {x: x, y: y} . See Rust: Using the Field Init Shorthand . Applicability We analysed popular Python libraries from the last few years using this script to compute: The number of keyword arguments which were of the form f(x=x) at invocation. The percentage of keyword arguments which had the form f(x=x) at invocation. The number of lines of code which could be saved by using this syntactic sugar to reduce the need for line wraps.

The purpose of this exercise was to compute statistics about the prevalence of this pattern and should not be interpreted as a recommendation that the proposed syntactic sugar should be applied universally. Statistic Polars FastAPI Rich HTTPX Number of keyword arguments of the form f(x=x) at invocation 1,654 1,408 566 759 Percentage of keyword arguments of the form f(x=x) at invocation 15.83% 28.11% 15.74% 45.13% Lines saved 170 35 62 117 Based on this, we note that the f(x=x) keyword argument pattern is widespread, accounting for anywhere from 15% to just below half of all keyword argument uses depending on the codebase.

Proposed Syntax While this feature has been proposed on numerous occasions with several different forms [1] [2] [3] [4] [5] , [6] we have opted to advocate for the f(x=) form for the following reasons: This feature has been proposed frequently over a ten year period with the f(x=) or f(=x) being by far the most commonly suggested syntax [1] [2] [6] . This strongly indicates that it is the most obvious notation. The proposed syntax closely matches the f-stri

The rest of this page is on the live site.