What is the Python <> operator

后端 未结 2 1650
無奈伤痛
無奈伤痛 2021-01-20 12:19

What exactly is the <> operator in Python, and why is it undocumented (as far as I can tell)?

Is it the same as != or is not

2条回答
  •  自闭症患者
    2021-01-20 12:49

    In Python 2.x, <> is the same as != (i.e. "not equal to", rather than is not which is "not identical to"), but the latter is preferred:

    The comparison operators <> and != are alternate spellings of the same operator. != is the preferred spelling; <> is obsolescent.

    In 3.x, <> has been removed and only != exists.

提交回复
热议问题