On Tue, Mar 22, 2016 at 11:52 PM, Jussi Piitulainen <jussi.piitulai...@helsinki.fi> wrote: > Now you can ask for the next item that satisfies a condition using a > generator expression: > > next(symbol for symbol in stream if not symbol.isspace()) > ---> '/' > > next(symbol for symbol in stream if not symbol.isspace()) > ---> '*'
Or use filter(), which is sometimes clearer: # You probably want a more sophisticated function here def nonspace(ch): return not ch.isspace() next(filter(nonspace, stream)) ChrisA -- https://mail.python.org/mailman/listinfo/python-list