better way to write this function

Chris cwitts at gmail.com
Mon Nov 26 04:11:31 EST 2007


On Nov 26, 10:51 am, Paul Rubin <http://phr...@NOSPAM.invalid> wrote:
> Chris <cwi... at gmail.com> writes:
> >     for i in range(int(round((len(lst)/n),0))): ...
>
> Ugh!!!  Not even correct (under future division), besides being ugly.
> I think you mean:
>
>    for i in xrange(len(lst) // n): ...
>
> Really though, this grouping function gets reimplemented so often that
> it should be built into the stdlib, maybe in itertools.

Beauty is in the eye of the beholder, but true... Looks crap :p



More information about the Python-list mailing list