/ makes preceding parameters positional-only; * makes following parameters keyword-only
In a function signature, the / marker (PEP 570, Python 3.8+) indicates that all parameters before it are positional-only: callers cannot pass them by keyword. This is useful when the parameter name is an implementation detail that you may want to change later without breaking callers, or when the name would conflict with a keyword. The * marker indicates that all parameters after it are keyword-only: callers must pass them by name. This is useful for optional flags and configuration parameters because it makes call sites self-documenting and prevents accidental positional argument mistakes. You can combine both: def f(a, b, /, c, *, d): a and b are positional-only, c can be positional or keyword, and d is keyword-only. These markers are part of the function signature and are enforced at call time with TypeError. They are a design tool for public APIs and for avoiding ambiguity in functions with many parameters.
def f(a, b, /): a and b must be passed positionally; f(a=1, b=2) raises TypeError.
def f(*, a, b): a and b must be passed by keyword; f(1, 2) raises TypeError.
Combined: def f(pos_only, /, normal, *, kw_only): mixes all three kinds.
*args collects extra positional arguments; **kwargs collects extra keyword arguments.
Trade-off: stricter signatures prevent misuse but can break callers if you change the marker later. Use them deliberately for public APIs.
Common mistake: adding / or * after parameters that existing callers pass by keyword, breaking compatibility.
Common mistake: confusing * as multiplication with * in a signature; the meaning depends on context.
Version note: / was introduced in Python 3.8 (PEP 570). * for keyword-only parameters has been available since Python 3.0.
0-2 years experience
2-5 years experience
5-8 years experience
8+ years experience