[Python-checkins] r46250 - sandbox/trunk/Doc/functional.rst

Jim Jewett jimjjewett at gmail.com
Thu May 25 23:20:19 CEST 2006


On 5/25/06, Raymond Hettinger <rhettinger at ewtllc.com> wrote:
> Inserted below are a few ideas that you may or may not want to include
> as part of a tutorial of functionals.


> Another variant on that theme is padding a short sequence with fill
> values so that zip() can form the sequence into a two dimensional array:
>
>     >>> s = range(11)
>     >>> zip(*[iter(chain(s, repeat(0,5)))]*5)
>     [(0, 1, 2, 3, 4), (5, 6, 7, 8, 9), (10, 0, 0, 0, 0)]

It is not at all obvious what this one does.  If you do use it, then
please put it after the rest of the izip section, including the
call-three-times-and-unpack example.

>    >>> zip(*[iter(s)]*3)

so that the parts other than chain and repeat don't seem as magical.

-jJ


More information about the Python-checkins mailing list