min() & max() functionality

Just van Rossum just at letterror.com
Fri Sep 1 20:23:14 CEST 2000

Paul-Michael Agapow wrote:
> Perhaps I've missed it in the documentation, but what does a hand-rolled
> sequence (i.e. my own class) need, so it can be used by min() and max()?
> I've implemented just about all the mutable sequence functionality in my
> own class (although it seems reasonable that only __len__() and
> __getitem__() would be be necessary) but calling either min or max on it
> sends Python into an infinite albeit interruptable loop. (Possibly
> relevant platform details: MacOS 9.04, Python IDE 1.52c1.)

Does your object work correctly in a for loop? It sounds like your
__getitem__ doesn't raise IndexError when it receives an index that's
too large.


More information about the Python-list mailing list