min() & max() functionality

Paul-Michael Agapow p.agapow at ic.ac.uk
Mon Sep 4 10:26:00 EDT 2000


Just van Rossum <just at letterror.com> wrote:
> 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()?
> 
> 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.

Bingo. I was throwing IndexError, _but_ wasn't throwing it at the right
times. Thanks Just.

-- 
Paul-Michael Agapow (p.agapow at ic.ac.uk), Biology, Imperial College
"Pikachu's special power is that he is monophyletic with lagomorphs ..."



More information about the Python-list mailing list