我有一个名为MyFilter
的python类。在我过滤列表的方法之一中:
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
当我删除有问题的行时,它会按预期运行。
正是如此。谢谢大家。我通过使用变量filter
实例化类的实例来测试类。:脸掌: