How to do this in Python? - A "gotcha"
sion at paintbox.UUCP
Wed Mar 18 17:23:05 CET 2009
Jim Garrison <jhg at 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?
def __eq__(self, other):
for x in iter(callable, sentinel()):
Writing a sensible sentinel.__init__ is left as an exercise....
More information about the Python-list