Supporting list()

Skip Montanaro skip at pobox.com
Mon Dec 17 10:51:59 EST 2012


> If using __getitem__ it needs to work with integers from 0 to len(f)-1,
> and raise IndexError for len(f), len(f+1), etc.

Ah, thanks.  I have a __getitem__ method, but it currently doesn't raise
IndexError.  (I'm indexing into a ring buffer, and the usage of the class
pretty much precludes indexing with an out-of-bounds index.)

S






More information about the Python-list mailing list