A newbie dictionary question
vroonhof at frege.math.ethz.ch
Sat Nov 6 16:44:40 EST 1999
Eric Jacobs <x at x.x> writes:
> > def __str__(self):
> > self.value
> Unrelated, but did you mean "return self.value"? It's
> legal to throw away values in Python.
Yes I did.
> > def __cmp__(self,other):
> > return self.nospaces() == other.nospaces()
> The __cmp__ is returning the wrong thing. It should return
> -1 for <, 0 for ==, or 1 for >. You probably want
> def __cmp__(self, other):
> return cmp(self.nospaaces(), other.nospaces())
Aaargghh. Of course. I feel stupid. Thanks a lot. I could have sworn
I wrote that. I guess it really was too late. It works fine now.
More information about the Python-list