Python class definition syntax

While it might not be syntactically incorrect to use the empty parentheses in a class definition, parentheses after a class definition are used to indicate inheritance, e.g:

class A(baseClass):
    ...

In Python, the preferred syntax for a class declaration without any base classes is simply:

class A:
    ...

Don’t use parentheses unless you are subclassing other classes.

The docs on the matter should give you a better understanding of how to declare and use classes in Python.

Leave a Comment

tech