[Python-ideas] itertools.chunks(iterable, size, fill=None)
Joao S. O. Bueno
jsbueno at python.org.br
Fri Jun 29 13:29:05 CEST 2012
On 29 June 2012 05:55, Michele Lacchia <michelelacchia at gmail.com> wrote:
> + 1 for the original proposal! I don't think splitting belongs to potential
> Il giorno martedì 26 giugno 2012 14:58:35 UTC+2, Simon Sapin ha scritto:
>> Le 26/06/2012 14:42, Joao S. O. Bueno a écrit :
>> > itertools.chunks(iterable, size=None, separator=None, fill=None)
>> > Requiring at leas one of size or separator to be set?
>> > This would also work for "for x in text.split('\n')" case.
>> I think that splitting an iterable on some separators or on a chunck
>> size are two completely different functions. Having the same function do
>> either is a bit confusing and I don’t see the benefit.
>> Or is there an use case in passing both parameters? What would it do
>> then, end the chunck after `size` elements or at `separator`, whichever
>> comes first?
Indeed - these are orthogonal features - but I think the ability to split on
a separator as an interator, if not as important as chunks, is missing as well.
Maybe add both?
>> Simon Sapin
>> Python-ideas mailing list
>> Python-ideas at python.org
More information about the Python-ideas