Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Python Object-Oriented Python Instant Objects Let's Make a Class!

Jonathan Davidson
Jonathan Davidson
1,641 Points

snake case

Why do we use CamelCase instead of snake_case when naming a class? I thought it was convention to use snake_case in python.

1 Answer

Steven Parker
Steven Parker
231,236 Points

The officially preferred naming conventions are documented in the PEP-8 Style Guide. They include:

  • variable and function names should be snake_case
  • class names should normally use the CapWords convention
  • constants are usually written in ALL_CAPITAL_LETTERS

Note that "camelCase" is not normally used in Python, and differs from CapWords (also known as StudlyCaps or PascalCase) in that the first letter is lower case.