Jim Garrison  <j...@acm.org> wrote:
>It's a shame the iter(o,sentinel) builtin does the
>comparison itself, instead of being defined as iter(callable,callable)
>where the second argument implements the termination test and returns a
>boolean.  This would seem to add much more generality... is
>it worthy of a PEP?

class sentinel:
    def __eq__(self, other):
        return termination_test()

for x in iter(callable, sentinel()):
    ...

Writing a sensible sentinel.__init__ is left as an exercise....

-- 
\S

   under construction

--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to