クラスの継承

入門Python3 6.3


続いてはクラスの継承です。

class Foo():
    def __init__(self,str):
        self.str = str
        
    def hello(self):
        print(self.str)

class Bar(Foo):
    pass

bar = Bar("hello world!")
bar.hello()
$ py main.py
hello world!

BarクラスがFooクラスを継承しています。

この辺の内容はC++C#でも学習済みなので特に特筆するようなこともないですね。