跟老齐学Python之编写类之三子类
关于类,看官想必已经有了感觉,看下面的代码,请仔细阅读,并看看是否能够发现点什么问题呢?
#!/usr/bin/envpython #coding:utf-8
classPerson: def__init__(self,name,lang,email): self.name=name self.lang=lang self.email=email
defauthor(self): returnself.name
classProgrammer: def__init__(self,name,lang,email,system,website): self.name=name self.lang=lang self.email=email self.system=system self.website=website
defpythoner(self): pythoner_list=[self.name,self.lang,self.email,self.system,self.website] returnpythoner_list
if__name__=="__main__": writer=Person("qiwsir","Chinese","qiwsir@gmail.com") python=Programmer("qiwsir","Python","qiwsir@gmail.com","Ubutun","qiwsir.github.io") print"Mynameis:%s"%writer.author() print"Iwriteprogramby:%s"%python.pythoner()[1]