[Python-Dev] make iter() return an empty iterator?

Kevin Jacobs <jacobs@bioinformed.com> bioinformed at gmail.com
Fri Aug 3 15:14:20 CEST 2007


On 8/3/07, Facundo Batista <facundobatista at gmail.com> wrote:
>
> 2007/8/3, Andrew Bennetts <andrew-pythondev at puzzling.org>:
>
> > I don't really think there's much reason to make "iter()" work.  As you
> say,
>
> What bad thing could happen if we make iter() work? If nothing, we
> should ask ourselves: which is the more intuitive behaviour to expect
> of iter()? To raise an exception or to return an empty iterator?
>
> I'm +0 for the latter.
>

-1.  I'm a heavy user of iterators on finite and infinite streams and, for
me, iter() is an error that I do not want to paper over.  The alternate
logic implies, e.g., len() should return 0.

-Kevin
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/python-dev/attachments/20070803/40c517a6/attachment.htm 


More information about the Python-Dev mailing list