python集合子类(列表继承)

2024-09-30 04:38:34 发布

您现在位置:Python中文网/ 问答频道 /正文

这是一个来自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类的实现)?在

请不要扔石头)谢谢你的回答


Tags: inself示例forinitvaluedefthis

热门问题