camel case
Camel case is a naming convention where you write a multi-word identifier without spaces, and use capitalization to mark word boundaries. The term is used broadly, but it’s often helpful to distinguish the two common variants:
lowerCamelCase: First word lowercasedUpperCamelCase: First word uppercased, commonly called Pascal case
Type a few words below to see how the same name looks in Pascal case (UpperCamelCase), camel case (lowerCamelCase), and snake_case:
Python’s style guide, PEP 8, recommends snake_case for function names, variable names, method names, and instance attributes. It also recommends UpperCamelCase for class names.
Example
Here’s a quick example illustrating camel case usage:
>>> class ClassName: # Camel case for class name
... def method_name(self):
... greeting = "Hello, World!"
... print(greeting)
...
>>> obj = ClassName()
>>> obj.method_name()
Hello, World!
In this example, ClassName follows camel case conventions.
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:
- How Do You Choose Python Function Names? (Tutorial)
- Python Classes: The Power of Object-Oriented Programming (Tutorial)
- Writing Beautiful Pythonic Code With PEP 8 (Course)
- How to Write Beautiful Python Code With PEP 8 (Quiz)
- How Do You Choose Python Function Names? (Quiz)
- Class Concepts: Object-Oriented Programming in Python (Course)
- Inheritance and Internals: Object-Oriented Programming in Python (Course)
- Python Classes - The Power of Object-Oriented Programming (Quiz)
Have a question about this? Mentor AI can show you examples, compare related terms, and point you to tutorials.