Can a simple a==b 'hang' in and endless loop?

Claudio Grondi claudio.grondi at freenet.de
Wed Jan 18 11:10:09 EST 2006


Fuzzyman wrote:
> Oops... my misreading, sorry.
> 
> The reason that, in Python, short ints have the same identity is not
> fickle - it's just True. Python creates a new reference (pointer) to
> the same object.
> 
> You're saying you want one comparison operator that for :
> 
> 
>>a=[1]
>>... many other statements here ...
>>b=[1]
> 
> 
> gives the result :
> 
> 
>>a    xx b    # False
>>a[0] xx b[0] # True
> 
> 
> What you're saying is that you don't consider a and b equal when they
> are container objects of the same type, with the same contents. That's
> very counter intuitive.
As also the fact, that when
a = [1,2.0,3L]
b = [1.0,2,3 ]
a==b # gives True
even if the objects in the lists are actually different,
or when the objects being members of the list redefine __eq__ so, that 
no matter how different they are, the lists always compare True.

Claudio
> 
> All the best,
> 
> 
> Fuzzyman
> http://www.voidspace.org.uk/python/index.shtml
> 



More information about the Python-list mailing list