On 6/3/2015 12:00 PM, BartC wrote:

That's a different matter. However, you appear to be wrong.

print (-12 is -12)

gives True. As does ("abc" is "abc"). I assume constructions for
immutable values will do the same (([10,20,30] is [10,20,30]) gives
False because the constructs are mutable, although it's difficult to see
how in that form).

(This is on 2.7, 3.1 and PyPy. On 3.4.3, (-12 is -12) gives False as you
say, although (12 is 12) gives True, so not even Python can make up its
mind how it's supposed to work!)

Implementation details not specified in the language definition are just that -- implementation details. The 'is' operator. which is carefully defined in the reference, has three uses:
1. test whether an object is None, or some other specific, special object.
2. for implementation developers, test whether the implementation details, including optimizations, are as intended. 3. (least important, and often leading to confusion when people make assumptions and extrapolate limited results) for users, discover implementation details.

--
Terry Jan Reedy

--
https://mail.python.org/mailman/listinfo/python-list

Reply via email to