python - 将@staticmethod 包装器用于魔术方法?
问题描述
在我的一个子类中,我想用以下方法覆盖父类__iter__
:
def __iter__(self):
yield from ()
但是,因为我没有引用self
in __iter__
,所以写成 pythonic / 可以接受:
@staticmethod
def __iter__():
yield from ()
解决方案
推荐阅读
- python - 将 PNG 转换为 Python
- sql-server - SQL Server:在存储过程中查找和删除索引提示
- python - 使用上下文管理器打开
- ldap - 使用 openldap 配置 hyperledger fabric-ca 服务器
- php - 在codeigniter中更改日期格式
- c++ - 如何在C ++中仅对容器内的类成员进行迭代器
- r - 如何根据 r 中的条件创建从 0 到 3 的变量?
- draftjs - 通过 Formik 中的 yup 验证 Draft-js EditorState
- swift - 在添加 4 个滑块值时,表达式太复杂,无法在合理的时间错误内解决
- c++ - 多重采样背景不显示