Python Iterables struggling using map() built-in

Ian Kelly ian.g.kelly at gmail.com
Sun Dec 7 13:27:07 EST 2014


On Dec 7, 2014 8:31 AM, "Ned Batchelder" <ned at nedbatchelder.com> wrote:
> NOTE: THIS EXAMPLE IS HORRIBLE.  This code is crazy-confusing, and should
never have been used as an example of iteration. It layers at least three
iterations on top of each other, making it very difficult to see what is
going on.  It uses "while iters" where "while True" would do exactly the
same thing (iters will never be false).

That's not quite correct; the "while iters" actually guards against the
case where the passed args are empty. With no sub-iterators, no
StopIteration would ever be raised, and the result would be an infinite
generator of empty tuples. The "while iters" makes it return immediately
instead.

So it seems this example is even more confusing than you thought.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20141207/94a6a2f2/attachment.html>


More information about the Python-list mailing list