Python-identity-operators-example
提供:Dev Guides
Python ID演算子の例
アイデンティティ演算子は、2つのオブジェクトのメモリ位置を比較します。 以下に説明するように、2つのアイデンティティ演算子があります-
Operator | Description | Example |
---|---|---|
is | Evaluates to true if the variables on either side of the operator point to the same object and false otherwise. | x is y, here is results in 1 if id(x) equals id(y). |
is not | Evaluates to false if the variables on either side of the operator point to the same object and true otherwise. | x is not y, here is not results in 1 if id(x) is not equal to id(y). |
例
上記のプログラムを実行すると、次の結果が生成されます-