Why is “3 in [3] == True” false? [duplicate]

戏子无情 提交于 2020-02-08 08:24:32

问题


Shouldn't it be parsed as (3 in [3]) == True since in and == have the same precedence? It's definitely not being parsed as 3 in ([3] == True) since that raises a TypeError. How else can it be parsed?

p.s. I'm aware that PEP 8 says "Don't compare boolean values to True or False using ==." This is just an example.

This stemmed from a dicussion on this question

来源:https://stackoverflow.com/questions/60122659/why-is-3-in-3-true-false

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!