A function signature can distinguish the item being processed from optional policies. A keyword-only flag makes call sites easier to read.
Worked example
def price(amount, /, *, tax=0):
return amount + tax
print(price(12, tax=2))Result
14Implementation notes
Keyword-only options help when several arguments share the same type. Swapping two boolean flags can otherwise remain valid Python while reversing behaviour.
Try it yourself
Move a keyword-only value into the positional argument list.
Open the Python example →Editorial date September 27, 2025 · Published December 6, 2026