python - 为什么过滤器会在父级上引发不可调用的错误
问题描述
我有一个名为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
当我删除违规行时,它按预期运行。
解决方案
就是这样。谢谢各位。我通过使用变量实例化类的实例来测试类filter
。:掌心:
推荐阅读
- cucumber - 可以从更高级别的黄瓜场景中调用空手道 DSL 吗?
- android - 如何在 android studio 中将多个项目合并/合并为一个?
- git - Jenkinsfile 中没有这样的用户 git commit 错误
- java - 将我的 Java 桌面应用程序隐藏在 VM 中是保护我的 Java 源代码的最佳方式吗?
- python - Python MySQL 装饰器检索行但返回无
- vue.js - Vue.js - 尝试编写一个计算来返回我的数据的子字符串
- node.js - webpacked express 服务器中的动态需求找不到模块
- angular - 在 .valid 和 .touched 子组件上显示字段错误消息
- r - updatePickerInput 在 R 闪亮中更改选项卡后不更新值
- vue.js - Vuejs:如果链接的 v-model 值更改,vue-color 不会更改选择器位置