Every instance method is expected to have at least one positional parameter. This parameter will reference the object instance on which the method
is called. Calling an instance method which doesn’t have at least one parameter will raise a TypeError
. By convention, this first
parameter is usually named self
.
Class methods, i.e. methods annotated with @classmethod
, also require at least one parameter. The only differences is that they will
receive the class itself instead of a class instance. By convention, this first parameter is usually named cls
.
Exceptions
Static methods (methods annotated with the @staticmethod
decorator) do not require any positional parameter. This rule will not raise
an issue on them.