[Python-Dev] Enhancing `iter'

Miki Tebeka miki.tebeka at zoran.com
Wed Feb 18 08:07:13 EST 2004


Hello All,

Currently `iter' 2'nd parameter is used for comparison.
I'd like to have the ability to give a function that will determine weather
to stop or not.

iter(range(10), lambda x: x > 7)
will stop at 8.
(There reverse logic might be uses as well: continue as long a `sentinal'
returns True.)

The only problem I can see is that someone might want to use a function
object as a sentinal, then `iter' won't know if to call the function or to
compare. However this seems very rare and can be solved by:
def f(x, y):
    ....
iter(something, lambda x: x == f)

Any thoughts/objections?

Bye.
--
-------------------------------------------------------------------------
Miki Tebeka <miki.tebeka at zoran.com>
http://www.cs.bgu.ac.il/~tebeka
The only difference between children and adults is the price of the toys.



More information about the Python-Dev mailing list