import abc
class Car(metaclass=abc.ABCMeta):
def __init__(self,model=None):
self.model = model
@abc.abstractmethod
def run(self):
pass
class ToyotaCar(Car):
def __init__(self, model,enable_auto_run=False):
super().__init__(model)
self.enable_auto_run = enable_auto_run
#継承したクラスでオーバーライドさせないとオブジェクトを生成した時にエラーになる
def run(self):
print('fast fun')
toyota_car = ToyotaCar('Lexus')
More than 3 years have passed since last update.
Register as a new user and use Qiita more conveniently
- You get articles that match your needs
- You can efficiently read back useful information
- You can use dark theme
List of users who liked
00