gpt4 book ai didi

Python 2+3 兼容代码 : Should I avoid six?

转载 作者:太空宇宙 更新时间:2023-11-03 14:53:46 25 4
gpt4 key购买 nike

本指南,Writing code that runs under both Python2 and 3 , 指出

Use the third party six module sparingly (i.e. only if necessary). One good use case is the reraise() method.

这是为什么?我认为 6 的重点是让 Python 2+3 兼容代码更容易。

最佳答案

我认为重点是尽可能避免 2/3 的特定构造,并且仅在您没有其他 native 选项时才使用 six 之类的东西 - 因为它增加了复杂性和额外的故障点代码。由于 six 伪造了一些东西来弥合差距,您可能会发现它并不总是按预期工作。

关于Python 2+3 兼容代码 : Should I avoid six?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44252261/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com