Is there any python operator that equivalent to javascript triple equal?

Is there any python operator that equivalent to javascript triple equal?

The ordinary == operator in Python already works much like the === operator in JavaScript, in that it wont do string conversions. However, it does not compare types.

>>> 1 == 1
False
>>> 1 == 1.0
True
>>> 1 == True
True

So we would say that Python doesnt have an exact equivalent to the JavaScript == or === operators. The way Python uses ==, without a === operator, is the norm. JavaScript (and PHP) are a bit unusual.

This last bit about bool might be a bit surprising, but bool is a subclass of int in Python.

Closest would maybe be the is operator. It returns True only if both variables point to the same object.

Is there any python operator that equivalent to javascript triple equal?

Leave a Reply

Your email address will not be published.