Re: Not understanding itertools.dropwhile()

2017-04-30 Thread Peter Otten
Jason Friedman wrote: > def test_to_start(s): > return "2" in s > > for line in itertools.dropwhile(test_to_start, data.splitlines()): > print(line) It's really all in the names: it could either be for line in dropwhile(test_to_drop, items): ... or for line in dropwhilenot(test_to

Re: Not understanding itertools.dropwhile()

2017-04-29 Thread Steve D'Aprano
On Sun, 30 Apr 2017 09:41 am, Jason Friedman wrote: > < start code > > > import itertools > > data = """Line1 > Line2 > > Line4 > Line5""" > > def test_to_start(s): > return "2" in s > > for line in itertools.dropwhile(test_to_start, data.splitlines()): > print(line) > > <---

Re: Not understanding itertools.dropwhile()

2017-04-29 Thread Terry Reedy
On 4/29/2017 7:41 PM, Jason Friedman wrote: < start code > import itertools data = """Line1 Line2 Line4 Line5""" def test_to_start(s): return "2" in s for line in itertools.dropwhile(test_to_start, data.splitlines()): print(line) < end code > I expect: $ python3

Not understanding itertools.dropwhile()

2017-04-29 Thread Jason Friedman
< start code > import itertools data = """Line1 Line2 Line4 Line5""" def test_to_start(s): return "2" in s for line in itertools.dropwhile(test_to_start, data.splitlines()): print(line) < end code > I expect: $ python3 dropwhile.py Line2 Line4 Line5 I get: $ pyth