Quick wins for a faster PC:
Repair Windows errors before they cause bigger problemsFix Now →Fix the driver behind crashes, sound loss and screen glitchesFind Drivers →Python function parameters can be positional-only, positional-or-keyword, or keyword-only; a parameter can also have a default value that makes it optional in a call. Use / to mark positional-only parameters and * to begin keyword-only parameters. These rules let you make calls clearer and keep an API’s public interface stable.
How the three parameter kinds work
Without a separator, an ordinary parameter is positional-or-keyword: callers can pass its value by position or with its name. A default value lets a caller omit that parameter. The slash and asterisk in a function definition change how callers may provide parameters.
def render(item, /, format="text", *, strict=False):
...
itemis positional-only because it appears before/.formatis positional-or-keyword and defaults to"text".strictis keyword-only because it follows*, and defaults toFalse.
The / and bare * are markers, not parameters you pass when calling the function. Python supports the slash syntax in function definitions from version 3.8 onward. See the Python 3.12 language reference.
What does / mean in a Python function definition?
Every parameter before / is positional-only. A caller must supply its value by position, not by parameter name.
Outdated Drivers Are Slowing You Down
One free scan finds every outdated or missing driver and matches the right update for your exact hardware.Free scan · exact hardware matchPC Slower Than It Used to Be?
A free scan shows the junk files, broken settings and background clutter dragging Windows down - then fixes them in one click.Free scan · Windows 10 & 11#1 Best Overall
def describe(value, /):
return str(value)
describe("report") # valid
describe(value="report") # TypeError
This is useful when the parameter’s name should not be part of the calling interface, or when you want to retain the freedom to rename it later. It can also let a function accept a keyword with the same name through **kwargs:
def foo(name, /, **kwds):
return name, kwds
foo("positional", name="keyword")
Here, name is bound positionally, while name="keyword" is collected in kwds. Without /, foo(1, name=2) would try to assign the same parameter twice.
Rank #2
What does * mean in a Python function definition?
A bare * ends the positional-or-keyword section and makes every following parameter keyword-only. You must pass those parameters by name:
def save(path, *, overwrite=False):
...
save("notes.txt", overwrite=True) # valid
save("notes.txt", True) # TypeError
A keyword-only parameter does not need a default. Without one, it is required:
Free tools Windows power users keep installed
One-click scans. No signup required.
def connect(host, *, timeout):
...
connect("example.com", timeout=10) # valid
connect("example.com") # TypeError
Parameters after a variadic positional parameter such as *args are keyword-only as well. The Python tutorial’s section on special parameters describes both forms.
How defaults make arguments optional
Write parameter=value in the definition to provide a default. Python uses that value only if the caller omits the parameter; an explicitly supplied value takes precedence.
def greet(name, greeting="Hello"):
return f"{greeting}, {name}!"
greet("Mina") # uses "Hello"
greet("Mina", "Welcome") # supplies greeting by position
greet("Mina", greeting="Hi") # supplies greeting by name
Defaults are evaluated once when the function is defined, so a mutable default such as a list is reused across calls. To create a fresh list for each call, use None as a sentinel and construct the list inside the function:
def append_item(item, items=None):
if items is None:
items = []
items.append(item)
return items
This avoids unintentionally sharing one list between calls. The pattern is also shown in the official Python tutorial.
The Tool Desk
Outbyte Driver Updater FREEFix the driver behind crashes, sound loss and screen glitchesFind Drivers →Outbyte PC Repair FREERepair Windows errors before they cause bigger problemsFix Now →Best Value
How to choose parameter kinds
| Kind | Use it when | Effect on callers |
|---|---|---|
Positional-only (/) |
The name has no useful public meaning, the position is the intended convention, arbitrary keywords must remain available, or you may want to rename the parameter without breaking callers. | Callers must provide the value by position and cannot rely on the parameter name. |
| Positional-or-keyword (ordinary parameter) | Either calling style is reasonable and you want to allow both. | Callers may provide the value by position or by name. |
Keyword-only (*) |
A descriptive name improves readability, or a positional value would be hard to interpret. | Callers must use the parameter name; a default determines whether it may be omitted. |
For example, a format option may be understandable as a keyword, while a flag such as strict is easier to read when written explicitly as strict=True. Positional-only parameters can insulate callers from parameter renames; as the Python Software Foundation’s tutorial puts it, “For an API, use positional-only to prevent breaking API changes if the parameter’s name is modified in the future.”
Diagnosing argument-binding TypeErrors
Python raises TypeError when a call does not match the function signature. Check the call against these rules:
- Positional-only parameter passed by name:
render(item="report")is invalid whenitemappears before/. - Keyword-only parameter passed by position:
render("report", "json", True)is invalid whenstrictfollows*. - Required parameter omitted: a parameter without a default must be supplied in an allowed way.
- Unknown keyword: a keyword must match a parameter name unless the function accepts arbitrary keywords with
**kwargs. - Value supplied twice: do not provide one parameter positionally and again by keyword, or repeat a keyword. For example,
render("report", format="json", strict=True, **{"strict": False})suppliesstricttwice.
When an error occurs, compare each argument with the signature from left to right: first positional values, then named values, and finally whether any required parameters remain unbound.
Inspecting a callable’s parameter kinds
For documentation, decorators, or other tools that need to examine a callable, Python’s inspect.signature() returns a Signature object. Its ordered parameters mapping identifies kinds such as POSITIONAL_ONLY, POSITIONAL_OR_KEYWORD, VAR_POSITIONAL, KEYWORD_ONLY, and VAR_KEYWORD. See the Python 3.12 inspect documentation.
Recommended Free Tools
import inspect
sig = inspect.signature(render)
for parameter in sig.parameters.values():
print(parameter.name, parameter.kind, parameter.default)
Check Python compatibility
Positional-only syntax using / requires Python 3.8 or later. If your project supports older interpreters, do not put that syntax in code that must run on them. The tutorial linked above documents Python 3.14.8; the language reference and inspect documentation linked here are for Python 3.12.15.
Quick Recap
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.




