■animal.py
class Animal: def __init__(self, name): self.name = name def call(self): print('こんにちは。%s さん' % (self.name))
■main.py
from animal import Animal from person import Person dog = Animal("犬") cat = Animal("猫") monkey = Animal("猿") p1 = Person("太郎") dog.call() cat.call() monkey.call() p1.speak() p1.call()
■出力
こんにちは。犬 さん こんにちは。猫 さん こんにちは。猿 さん 私は太郎 です。 こんにちは。太郎 さん