Positional-only parameters are function parameters that must be supplied strictly based on their order in the function call, explicitly prohibiting the use of keyword arguments (e.g.,Documentation Index
Fetch the complete documentation index at: https://docs.syntblaze.com/llms.txt
Use this file to discover all available pages before exploring further.
name=value) for those specific parameters. Introduced in Python 3.8 (PEP 570), they are defined in a function signature using a forward slash (/).
All parameters declared before the / are enforced as positional-only. Parameters declared after the / retain standard Python behavior (they can be passed by position or by keyword) unless further modified by other signature operators.
Syntax
Mechanics and Behavior
When a function is invoked, the Python interpreter maps the provided arguments to the signature. If an argument corresponding to a positional-only parameter is passed using keyword syntax, the interpreter raises aTypeError.
Signature Composition
The/ operator can be combined with the * operator (which enforces keyword-only parameters) to create a strictly partitioned function signature. This establishes clear boundaries for argument resolution:
pos_only: Must be passed by position./: Demarcates the end of positional-only parameters.standard: Can be passed by position or keyword.*: Demarcates the start of keyword-only parameters.kw_only: Must be passed by keyword.
Default Values
Positional-only parameters support default values. However, standard rules apply: a non-default positional-only parameter cannot follow a default positional-only parameter.Master Python with Deep Grasping Methodology!Learn More





