This seems sane:

    >>> it = iter(range(10))
    >>> for i in it:
    ...   if i >= 3:
    ...     break
    ...
    >>> list(it)
    [4, 5, 6, 7, 8, 9]

As does this:

    >>> it = iter(list(range(10)))
    >>> for i in it:
    ...   if i >= 3:
    ...     break
    ...
    >>> list(it)
    [4, 5, 6, 7, 8, 9]

This not so much:

    >>> it = range(10)
    >>> for i in it:
    ...   if i >= 3:
    ...      break
    ...
    >>> list(it)
    [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]

Note to self: range(10) is an iterator factory, not an iterator.


Marko
-- 
https://mail.python.org/mailman/listinfo/python-list

Reply via email to