Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #44597

Re: Why chunks is not part of the python standard lib?

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!eternal-september.org!feeder.eternal-september.org!mx05.eternal-september.org!.POSTED!not-for-mail
From Paul Rubin <no.email@nospam.invalid>
Newsgroups comp.lang.python
Subject Re: Why chunks is not part of the python standard lib?
Date Wed, 01 May 2013 09:30:19 -0700
Organization Nightsong/Fort GNOX
Lines 7
Message-ID <7xy5byacis.fsf@ruckus.brouhaha.com> (permalink)
References <CAP5i+tYC+cMtseEduTm76LXkaP1Hh-Tz-_HipO7LsURtnuwtOw@mail.gmail.com> <mailman.1219.1367425160.3114.python-list@python.org>
Mime-Version 1.0
Content-Type text/plain; charset=us-ascii
Injection-Info mx05.eternal-september.org; posting-host="d94d289a4df6ae47ea4d4f8b2ae808e7"; logging-data="1954"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+zEsnGmlIZMV/X9mwjOp7u"
User-Agent Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux)
Cancel-Lock sha1:EhqFdG61nunaiBUUAIRDzqIXAt8= sha1:gNk20M56lI5mXvVlOr/2jzPtbB8=
Xref csiph.com comp.lang.python:44597

Show key headers only | View raw


Serhiy Storchaka <storchaka@gmail.com> writes:
> def chunks(seq, size):
>     return [seq[i: i + size] for i in range(0, len(seq), size)]

That's just for lists.  An itertools version would work with arbitrary
iterables.  I've also had to rewrite that function more times than seems
proper.

Back to comp.lang.python | Previous | NextPrevious in thread | Find similar | Unroll thread


Thread

Re: Why chunks is not part of the python standard lib? Serhiy Storchaka <storchaka@gmail.com> - 2013-05-01 19:19 +0300
  Re: Why chunks is not part of the python standard lib? Paul Rubin <no.email@nospam.invalid> - 2013-05-01 09:30 -0700

csiph-web