Skip to main content

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 use collections.
    • Use abc if you need pure OOP style abstract classes. Use NotImplementedError exceptions with overrides.
    • Mixin should be named with Mixin suffix such as class LoginRequiredMixin which can be used in multiple inheritance.
  • 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