这是一个来自Luts“Learning Python”中关于带继承的内置类扩展的示例(“newbies stucked”部分):
class Set(list):
def __init__(self, value = []):
list.__init__([]) #What is this for? when I removed this
#line nothing changed (question 1)
self.concat(value)
def concat(self, value):
for x in value:
if not x in self:
self.append(x)
(问题2)list类是否有存储数据的属性?是否可以将其视为Python代码(我是指list类的实现)?在
请不要扔石头)谢谢你的回答
目前没有回答
相关问题 更多 >
编程相关推荐