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

Fuzzyman fuzzyman at gmail.com
Thu Jan 19 06:34:30 EST 2006


(If I understand correctly...)

The reason he is looking for it, is in order to assert that Python
'comparison' is broken.

Part of this is because of his assertation that the term 'value' has no
meaning in Python.

He bases this on the fact that Java and C define 'value' to mean the
pointer when the object is mutable.

In fact Python defines value much more clearly. Value is *obviously*
type dependent. (This is why in Python you can implement your own
comparison methods).

For integers and floats, Python defines the value to be the numerical
value.

For strings it defines it to be the contents of the string.

For mutable objects it defines it to be the contents of the object, if
the object types are the same. i.e. [1] == [1], [1] != (1,)

For user defined classes, you are able to build your own definition of
value into the object - this doesn't prevent stupidity.

Python doesn't have a comparison operator analagous to his reference
languages - but IMHO Python is better here. He can achieve what he
wants by subclassing the built in datatypes and overriding the
comparison methods to behave as he desires.

All the best,

Fuzzyman
http://www.voidspace.org.uk/python/index.shtml




More information about the Python-list mailing list