What's the value of "None" between 2.1.1 and 1.5.2

Brian Quinlan brian at sweetapp.com
Fri Nov 30 04:34:37 CET 2001


> >>> class MuchoGrande:
> 	def __cmp__(self, other):
> 		return 1	# larger than anything else
> 	def __repr__(self):
> 		return "MuchoGrande"
> 

I'd change that to:

def __cmp__(self, other):
	if ininstance(other, MuchoGrande):
		return 0
	else:
		return 1

That way you the result of cmp won't depend on the order of the
arguments.

Cheers,
Brian





More information about the Python-list mailing list