Is there a naming convention I should follow with classes?


#1

Question

Is there a naming convention I should follow with classes?

Answer

It’s ultimately up to you, but following a convention can help make your code look much cleaner overall. It also may end up depending on where you work because some companies enforce their own code conventions.
For most people, class names will be capitalized and all one word, unlike how we’ve been writing variables with underscores so far.
As a general rule, your class names should be as descriptive as possible, leaving as little room for ambiguity as possible. For example, naming a class MyClass is totally fine, but tells me or anyone else reading your code absolutely nothing about what the class does. Naming a class HTMLPageTitleScraper, on the other hand, tells me exactly what the class does!


FAQ: Learn Python - Introduction to Bitwise Operators - Why Use Classes?