Python › Functions & Scope
How do positional-only parameters (using a bare '/' in the parameter list, Python 3.8+) restrict how certain parameters can be passed?
AdvancedAnswer
Placing a bare '/' in the parameter list marks every parameter BEFORE it as positional-only — callers CANNOT pass them by keyword name, useful for parameters whose NAME isn't meant to be part of the function's stable public API (letting you rename it later without breaking callers who used the keyword form).
def divide(a, b, /):
return a / b
divide(10, 2) # OK: positional
# divide(a=10, b=2) # Error: 'a' and 'b' are positional-only, can't use as keywordsReal-world example Preventing callers from depending on a parameter's exact NAME as part of the function's API contract, giving you freedom to rename it later.