kebab case
Kebab case is a naming convention that joins the words of a compound name with hyphens and keeps every letter lowercase, as in max-retries or user-profile. The name comes from the way the hyphens skewer the words together, like chunks of food on a kebab.
Python can’t use kebab case for identifiers. A hyphen is the subtraction operator, so the parser reads max-retries = 3 as an attempt to assign to the expression max - retries and raises a SyntaxError. That’s why PEP 8 prescribes snake case for variable, function, and module names.
Kebab case still shows up all over a Python project, in the places where a name is data rather than code. Packaging normalizes every distribution name to kebab case, so Friendly_Bard on PyPI resolves to friendly-bard.
The keys of the [project] table in pyproject.toml follow the same style, including requires-python and optional-dependencies. Command-line flags such as --dry-run use it too, along with URL slugs and CSS property names such as background-color.
The comparison below drops one name into each of those spots, so you can watch the hyphen survive wherever the name is data and trip the parser the moment it becomes code:
Example
Say you’re adding a retry limit to a backup script. The flag reads naturally in kebab case, and argparse converts it to a valid attribute name on the way in:
>>> import argparse
>>> parser = argparse.ArgumentParser(prog="backup")
>>> _ = parser.add_argument("--max-retries", type=int, default=1)
>>> args = parser.parse_args(["--max-retries", "3"])
>>> args
Namespace(max_retries=3)
>>> args.max_retries
3
argparse derives the destination name from the first long option, stripping the leading -- and swapping each internal hyphen for an underscore. The kebab case spelling lives on the command line, where it’s conventional, and the snake case spelling lives in the Python code, where it has to.
Related Resources
Tutorial
How to Write Beautiful Python Code With PEP 8
Learn how to write readable, high-quality Python code by following the PEP 8 style guide and using linters and autoformatters to enforce it.
For additional information on related topics, take a look at the following resources:
- Single and Double Underscore Naming Conventions in Python (Course)
- Build Command-Line Interfaces With Python's argparse (Tutorial)
- How to Manage Python Projects With pyproject.toml (Tutorial)
- Building Command Line Interfaces With argparse (Course)
- Everyday Project Packaging With pyproject.toml (Course)
- Writing Beautiful Pythonic Code With PEP 8 (Course)
- How to Write Beautiful Python Code With PEP 8 (Quiz)
- Build Command-Line Interfaces With Python's argparse (Quiz)
- How to Manage Python Projects With pyproject.toml (Quiz)
Have a question about this? Mentor AI can show you examples, compare related terms, and point you to tutorials.
By Martin Breuss • Updated Oct. 20, 2026