为什么一个过滤器在父类上抛出一个不可调用的错误?

问题描述 投票:0回答:1

我有一个名为 MyFilter. 在其中一个方法中,我过滤了一个列表。

def __gatherCommits(self, head, count=2, commits=[]):
    next_commits = self.repo.iter_commits(head, max_count=count)
    filtered_commits = list(filter(lambda x: x.committed_date == self.current_day, next_commits))

最后一行引起了一个错误。

File "MyFilter.py", line 22, in __gatherCommits
    filtered_commits = list(filter(lambda x: x.committed_date == self.current_day, next_commits))
TypeError: 'MyFilter' object is not callable

当我删除这一行时,它就会像预期的那样运行。

python callable
1个回答
0
投票

正是这样。谢谢大家。我是通过实例化一个类的实例来测试这个类的,这个类的变量是 filter...:面部掌心。

© www.soinside.com 2019 - 2024. All rights reserved.