Skip to main content
A positional parameter is a function parameter that receives its argument based strictly on the order (position) in which the arguments are passed during the function call. The Python interpreter binds the arguments to the parameters from left to right. In a standard function definition, parameters are positional by default unless explicitly called with keyword arguments.

Positional-Only Parameters

Introduced in Python 3.8, the forward slash / syntax explicitly restricts parameters to be positional-only. Any parameter defined before the / cannot be passed as a keyword argument. This enforces strict API boundaries at the signature level.

Arbitrary Positional Parameters (*args)

Python allows functions to accept an arbitrary number of positional arguments using the unpacking operator *. The interpreter packs all remaining positional arguments provided in the call into a single tuple bound to this parameter.

Syntax Rules and Constraints

When defining and invoking functions with positional parameters, the Python parser enforces strict ordering rules:
  1. Definition Order: In the function signature, standard positional parameters without default values must precede positional parameters with default values.

Valid

def func(a, b=5): pass

SyntaxError: non-default argument follows default argument

def func(a=5, b): pass

Tired of Poor Python Skills? Fix That With Deep Grasping!Learn More