Does '!=' equivelent to 'is not'

Gabriel Genellina gagsl-py2 at yahoo.com.ar
Wed Jun 18 03:45:54 EDT 2008


En Tue, 17 Jun 2008 23:04:16 -0300, Asun Friere <afriere at yahoo.co.uk> escribió:

> On Jun 17, 5:33 pm, "Gabriel Genellina" <gagsl-... at yahoo.com.ar>
> wrote:
>> En Tue, 17 Jun 2008 02:25:42 -0300, Lie <Lie.1... at gmail.com> escribió:
>
>>
>> > Basically 'a is b' and 'not(a is b)' is similar to 'id(a) == id(b)'
>> > and 'not(id(a) == id(b))'
>>
>> No.
> ...
>> ... The above statement is not. A counterexample:
>>
>> py> [] is []
>> False
>> py> id([])==id([])
>> True
>>
> But that's not what he said, he used 'a' and 'b' which are names, not
> anonymous objects.
> Fairer would be,
> a = [];b = []
> id(a) == id(b)

If you limit yourself to interpret 'a' and 'b' as actual names, yes, the statement is true. But I thought of them as placeholders or metasyntactic names - like in "abs(x) returns the absolute value of x", where x may represent *any* expression, not just a single name. Under this general interpretation the statement is not true anymore.

(This thread is getting way above 10000cp...)

-- 
Gabriel Genellina




More information about the Python-list mailing list