【发布时间】:2020-08-03 02:50:09
【问题描述】:
所以我最近一直在使用列表,我正在尝试让一个特殊的类工作,所以我编写了一个 for 循环来测试基本功能,但它只是给了我这个回溯:
Traceback (most recent call last):
File "C:\Users\User\Desktop\nice code\v2.py", line 13, in <module>
if Lenlist == len.lenList(len.listLen(List=len.list(list=List().list()))): print(Lenlist);
File "C:\Users\User\Desktop\nice code\v2.py", line 3, in lenList
def lenList(self, list=list): return len(list);
TypeError: 'List' object is not callable
这里是你的来源:
class List:
List = list('list');
def lenList(self, list=list): return len(list);
def listLen(self, List=len): return list(List);
def lenlist(self, len=list): return self.lenList(list=len);
def list(self, list=list): return self.List;
def listlen(self, len=len): return self.list(list=len);
len = List();
Lenlist = 0;
for Len in len.listLen(List=len.list(list=List().list())):
if Len in list(len.listLen(List=len.list(list=Len))):
Lenlist += list(len.listLen(List=len.list(list=Len))).count(Len);
if Lenlist == len.lenList(len.listLen(List=len.list(list=List().list()))): print(Lenlist);
我期望它打印 List.List 的长度。我已经尝试用关键字替换所有位置参数。
【问题讨论】:
-
len = List()隐藏内置函数。 -
只是想在此处留下此评论,因为... 哇!。
lenlistception。可能口译员也惊讶于你使用了多少lenlistlen`,这让他有点害怕 -
您可能需要考虑从
list派生您的课程。 docs.python.org/3/tutorial/classes.html#inheritance
标签: python python-3.x list oop