Python 中列表、元组或集合的合适类型(来自打字模块)是什么
What is a suitable type (from the typing module) for list, tuple or set in Python
我遇到的一些:
- typing.ItemsView
- typing.AbstractSet
- typing.Collection
- typing.Container
你觉得哪一个最合适?
如评论中所述,typing.union 是一个不错的选择,也如评论中所述,请尝试查看您的函数使用的是什么“实现”。
我觉得typing.Collection is the one that covers all of them, but you might be doing something that only needs typing.Iterable.
在不了解更多关于你在做什么的情况下很难说。
我遇到的一些:
- typing.ItemsView
- typing.AbstractSet
- typing.Collection
- typing.Container
你觉得哪一个最合适?
如评论中所述,typing.union 是一个不错的选择,也如评论中所述,请尝试查看您的函数使用的是什么“实现”。
我觉得typing.Collection is the one that covers all of them, but you might be doing something that only needs typing.Iterable.
在不了解更多关于你在做什么的情况下很难说。