I have read that this is the best way to implement an abstract class in Python (as opposed to the abc
module):
class Animal(object):
def speak(self):
raise NotImplementedError()
class Duck(Animal):
def speak(self):
print("quack")
class Cat(Animal):
def speak(self):
print("meow")
However, should I use abstract classes? Should I or should I not just use one less class like so:
class Duck(object):
def speak(self):
print("quack")
class Cat(Animal):
def speak(self):
print("meow")