2018-05-11 17:06 GMT+03:00 Clint Hepner <clint.hep...@gmail.com>: > > > (This reminds that I wish ``iter`` could take a predicate instead of a > sentinel as its second argument. Then > you could just write > > for cmd in iter(get_command, lambda x: x.token == CMD_QUIT): > cmd.do_something() > ) > > But you can do it right now:
class P: def __init__(self, key): self.key = key def __eq__(self, other): return self.key(other) for cmd in iter(get_command, P(lambda x: x.token == CMD_QUIT)): cmd.do_something() With kind regards, -gdg
_______________________________________________ Python-ideas mailing list Python-ideas@python.org https://mail.python.org/mailman/listinfo/python-ideas Code of Conduct: http://python.org/psf/codeofconduct/