A question on modification of a list via a function invocation

Chris Angelico rosuav at gmail.com
Thu Sep 7 23:11:51 EDT 2017


On Fri, Sep 8, 2017 at 1:01 PM, Rustom Mody <rustompmody at gmail.com> wrote:
>
>> Can you show an actual false positive (two distinct objects for which `is`
>> returns True) or false negative (the same object given as both operands for
>> `is` nevertheless returns False)? In the absence of any actual bugs in the
>> definition, I maintain that it is sufficient.
>
> You are not paying attention — the example above I gave in which
> python arbitrarily hi-handedly, inconsistently manifests different behavior
> between integer 1 and tuple (1,2)

You started with the assumption that the tuple (1,2) is the same as
the tuple (1,2). This is a false assumption; they are equal, but they
are not identical. How does your mathematical model cope with this?

>>> x = 1
>>> y = 1.0
>>> x == y
True
>>> x is y
False

There is no way that a compliant Python implementation can give any
other results for these expressions. These values are equal but not
identical. It's the same with the integers and tuples in your example,
except that there, Python is permitted to optimize by using the same
object.

Stop thinking about mathematics and assuming that (a) it is the
perfect way to explain software, and (b) we all have the same basis
you do. Start thinking about programming languages from a different
basis... you might actually learn something. Or just read what Steve
and I have been saying.

ChrisA



More information about the Python-list mailing list