Good use for itertools.dropwhile and itertools.takewhile
neilc at norwich.edu
Wed Dec 5 19:16:04 CET 2012
On 2012-12-05, Nick Mellor <thebalancepro at gmail.com> wrote:
> Hi Neil,
> Here's some sample data. The live data is about 300 minor
> variations on the sample data, about 20,000 lines.
This slight variation on my first groupby try seems to work for
the test data.
prod = 
desc = 
for k, g in itertools.groupby(s.split(),
key=lambda w: any(c.islower() for c in w)):
if prod or k:
return [' '.join(prod), ' '.join(desc)]
More information about the Python-list