On Sun, Feb 1, 2015 at 9:55 AM, Steven D'Aprano
<steve+comp.lang.pyt...@pearwood.info> wrote:
> Steven D'Aprano wrote:
>
>> len tries to call __len__ if it exists, and if not, it tries walking the
>> iterable counting items.
>
> Hmmm, I may have mis-remembered that. Perhaps I'm thinking of Ruby.

I think you just got it backward. iter will call __iter__ if it
exists, and will try to fall back on __len__ and __getitem__ to
iterate otherwise.
-- 
https://mail.python.org/mailman/listinfo/python-list

Reply via email to