Good use for itertools.dropwhile and itertools.takewhile
ian.g.kelly at gmail.com
Wed Dec 5 16:33:14 CET 2012
On Wed, Dec 5, 2012 at 7:34 AM, Neil Cerutti <neilc at norwich.edu> wrote:
> Well, shoot! Then this is a job for groupby, not takewhile.
The problem with groupby is that you can't just limit it to two groups.
>>> prod_desc("CAPSICUM RED fresh from QLD")
['QLD', 'fresh from']
Once you've got a false key from the groupby, you would need to
pretend that any subsequent groups are part of the false group and
tack them on.
More information about the Python-list