On 03/06/2015 17:00, BartC wrote:
On 03/06/2015 13:08, Marko Rauhamaa wrote:
BartC <b...@freeuk.com>:
To 'variable' and 'type', you might need to add 'value' to make it more
complete.
'Value' and 'object' are indeed synonymous as long as you keep in mind
that:
>>> -12 == -12
True
>>> -12 is -12
False
IOW, the literal expression -12 happens to construct a fresh
value/object each time CPython parses it.
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!)
3.4.3:
print (-12 is -12) => False
print (12 is 12) => True
print (20000000000000000000 is 20000000000000000000) => True
The others all give True in all cases. It seems that older Python
versions have a purer object model.
No, you don't understand how cPython does things.
--
My fellow Pythonistas, ask not what our language can do for you, ask
what you can do for our language.
Mark Lawrence
--
https://mail.python.org/mailman/listinfo/python-list