Classes
The following convention should be followed for class
naming:
- Avoid inbuilt names.
- Classes names should always be
PascalCase
. i.e.MyClass
- Abstract Classes and Mixins
- Use abstract containers if need to override datatypes.
- If you must build datatypes based on inbuilt class use PascalCase. i.e.
MyDict(dict):
. Although this is not recommended and you should usecollections
.
- If you must build datatypes based on inbuilt class use PascalCase. i.e.
- Use
abc
if you need pure OOP style abstract classes. UseNotImplementedError
exceptions with overrides. - Mixin should be named with
Mixin
suffix such asclass LoginRequiredMixin
which can be used in multiple inheritance.
- Use abstract containers if need to override datatypes.
- Describe the class responsibility in name clearly when possible.
- Custom Exceptions should always be named ending with
Error
i.e.MyCustomError
Example
class HelloWorld:
pass
class HelloWorldError(Exception):
pass