Status of PEPs?

Ville Vainio ville at
Fri Jul 2 17:45:55 CEST 2004

>>>>> "Duncan" == Duncan Booth <me at> writes:

    Duncan> Or for those of a less masochistic inclination, just use a
    Duncan> for loop:

    Duncan> for a in iter(getobject, None):

Cute. For those too lazy to check:

    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

(I bet many, including me, haven't heard of this).

It kinda loses some of its appeal when getobject() takes arguments,
though - you'll have to go for lambda then:

for a in iter(lambda : getobject(2,"hi"), None):

Ville Vainio

More information about the Python-list mailing list