最初のpythonクラスの実装
453 ワード
[zcm@python #105]$cat a.py
#!/usr/bin/python
class Simple:
def __init__(self, name):
self.name = name
def hello(self):
print self.name + " says hi."
class Simple2(Simple):
def goodbye(self):
print self.name + " says goodbye."
me = Simple2("Tim")
me.hello()
me.goodbye()
[zcm@python #106]$
実行結果:
[zcm@python #106]$./a.py Tim says hi. Tim says goodbye. [zcm@python #107]$