From: Josh C. <jc...@nc...> - 2008-04-14 14:10:07
|
On Mon, 14 Apr 2008, Philipp Kraft wrote: > Thank you nitro for the answer, > while _getitem__ and __len__ are quite trivial, I've still got problems with > __iter__. I think that if you do __getitem__ right you get simple iteration for free. Python will handle 'for it in foo:' by using indices 0, 1, 2.... Out of range has to do the right thing, like raise IndexError. Josh |