Python allows developers to customize how code is interpreted by defining special methods (also called magic methods). For example, it is possible to override how the multiplication operator (``++a * b++``) will apply to instances of a class by defining in this class the ``++__mul__++`` and ``++__rmul__++`` methods. Whenever a multiplication operation is performed with this class, the Python interpreter will call one of these methods instead of performing the default multiplication.
Each special method expects a specific number of parameters. The Python interpreter will call these methods with those parameters. Calls to a special method will throw a ``++TypeError++`` if it is defined with an incorrect number of parameters.
=== on 11 Feb 2020, 17:22:41 Nicolas Harraudeau wrote:
Special methods which are out of scope for this rule: ++__new__++, ++__init__++, ++__call__++
These methods have no maximum number of parameters and require at minimum a "self" parameter. Missing a "self" parameter is already covered by RSPEC-5720.