[英]What is a suitable type (from the typing module) for list, tuple or set in Python
Some that I've encountered:我遇到的一些:
Which one do you think is most suitable?你觉得哪一款最合适?
as mentioned in the comments typing.union is a nice option, also as mentioned in the comments try and see what one "implements" what your function uses.正如评论中提到的那样, typing.union是一个不错的选择,也如评论中提到的那样,尝试看看你的函数使用的是什么“实现”。
I thinktyping.Collection is the one that covers all of them, but you might be doing something that only needs typing.Iterable .我认为Typing.Collection是涵盖所有这些的一个,但您可能正在做一些只需要Typing.Iterable 的事情。
without knowing more about what you are doing it is hard to say.如果不了解更多关于你在做什么,就很难说。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.