Sequence splitting
Paul Rubin
http
Fri Jul 3 04:02:56 EDT 2009
Steven D'Aprano <steve at REMOVE-THIS-cybersource.com.au> writes:
> I've never needed such a split function, and I don't like the name, and
> the functionality isn't general enough. I'd prefer something which splits
> the input sequence into as many sublists as necessary, according to the
> output of the key function. Something like itertools.groupby(), except it
> runs through the entire sequence and collates all the elements with
> identical keys.
No really, groupby makes iterators, not lists, and it you have to
develop quite a delicate sense of when you can use it without having
bugs caused by the different iterators it makes getting advanced at
the wrong times. The concept of a split function that actually works
on lists is useful. I'm neutral about whether it's worth having a C
version in the stdlib.
More information about the Python-list
mailing list