iter(callable, sentinel)

Simon Forman rogue_pedro at yahoo.com
Thu Jul 27 13:54:52 EDT 2006


Will McGugan wrote:
> Hi,
>
> I've been using Python for years, but I recently encountered something
> in the docs I wasnt familar with. That is, using two arguements for
> iter(). Could someone elaborate on the docs and maybe show a typical use
> case for it?
>
>
> Thanks,
>
> Will McGugan
>
> --
> work: http://www.kelpiesoft.com
> blog: http://www.willmcgugan.com

I just found out about that recently too.

help(iter) shows this:
Help on built-in function iter in module __builtin__:

iter(...)
    iter(collection) -> iterator
    iter(callable, sentinel) -> iterator

    Get an iterator from an object.  In the first form, the argument
must
    supply its own iterator, or be a sequence.
    In the second form, the callable is called until it returns the
sentinel.




More information about the Python-list mailing list