I was just looking up the way to go for defining an abstract base class in Python, when I found the abc
module (https://docs.python.org/3/library/abc.html).
After a bit of reading I saw the following class:
class C(ABC):
@abstractmethod
def my_abstract_method(self, ...):
...
@classmethod
@abstractmethod
def my_abstract_classmethod(cls, ...):
...
Wondering about the triple dots, which I found it is called the Ellipsis
(https://docs.python.org/3/library/constants.html#Ellipsis). I've seen and used it so far only in combination with type hints, where it maked perfectly sense.
But why would one use the Ellipsis in the definition of an abstract method? Personally, I would either do
def my_abstract_method(self):
raise RuntimeError("NotImplemented")
or
def my_abstract_method(self):
pass
So why is the Ellipsis preferred over pass
in the official documentation? Is it just opiniated?