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


Groups > comp.lang.python > #44596

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!newsfeed.xs4all.nl!newsfeed4.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <python-python-list@m.gmane.org>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.001
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'subject:not': 0.03; 'sized': 0.07; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'subject:Why': 0.09; 'def': 0.12; '3],': 0.16; 'chunks': 0.16; 'iterator': 0.16; 'range(0,': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'size):': 0.16; 'url:312443': 0.16; 'url:djangoproject': 0.16; 'url:how-do-you-split-a-list- into-evenly-sized-chunks-in-python': 0.16; 'subject:python': 0.16; 'split': 0.19; 'python?': 0.22; 'header:User-Agent:1': 0.23; 'header:X-Complaints-To:1': 0.27; 'header:In-Reply-To:1': 0.27; 'function': 0.29; 'url:code': 0.29; 'subject:the': 0.34; 'library.': 0.36; 'subject:?': 0.36; 'should': 0.36; 'list': 0.37; '8bit%:86': 0.38; 'to:addr:python-list': 0.38; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'how': 0.40; 'kind': 0.63; 'url:ticket': 0.84; 'mistakes': 0.93
X-Injected-Via-Gmane http://gmane.org/
To python-list@python.org
From Serhiy Storchaka <storchaka@gmail.com>
Subject Re: Why chunks is not part of the python standard lib?
Date Wed, 01 May 2013 19:19:07 +0300
References <CAP5i+tYC+cMtseEduTm76LXkaP1Hh-Tz-_HipO7LsURtnuwtOw@mail.gmail.com>
Mime-Version 1.0
Content-Type text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding 8bit
X-Gmane-NNTP-Posting-Host 37.19.199.183
User-Agent Mozilla/5.0 (X11; Linux i686; rv:17.0) Gecko/20130329 Thunderbird/17.0.5
In-Reply-To <CAP5i+tYC+cMtseEduTm76LXkaP1Hh-Tz-_HipO7LsURtnuwtOw@mail.gmail.com>
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.1219.1367425160.3114.python-list@python.org> (permalink)
Lines 18
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1367425160 news.xs4all.nl 15871 [2001:888:2000:d::a6]:44609
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:44596

Show key headers only | View raw


01.05.13 09:26, Ricardo Azpeitia Pimentel написав(ла):
> After reading How do you split a list into evenly sized chunks in
> Python?
> <http://stackoverflow.com/questions/312443/how-do-you-split-a-list-into-evenly-sized-chunks-in-python>
> and seeing this kind of mistakes happening
> https://code.djangoproject.com/ticket/18972 all the time.
>
> Why is not a |chunks| function in itertools?

Because not every 1 line function needs to be in the standard library.

> |chunks([1,  2,  3,  4,  5],  3)
> # Should return [[1, 2, 3], [4, 5]] or the iterator equivalent.|

def chunks(seq, size):
     return [seq[i: i + size] for i in range(0, len(seq), size)]

Back to comp.lang.python | Previous | NextNext 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