[Python-checkins] peps: In the examples section, show how zip() is reversible. (original) (raw)

georg.brandl python-checkins at python.org
Wed Mar 23 21:22:30 CET 2011


http://hg.python.org/peps/rev/e09ccf8ee11d changeset: 21:e09ccf8ee11d user: Barry Warsaw <barry at python.org> date: Wed Jul 19 04:19:54 2000 +0000 summary: In the examples section, show how zip() is reversible.

Patches to the reference implementation:

__getitem__() raises IndexError immediately if no sequences were
given.

__len__() returns 0 if no sequences were given.

__cmp__() new method

Added a little more explanation to raise-a-TypeError-for-zip(a)

Added `fold' as one of the alternative names proposed.

files: pep-0201.txt | 57 +++++++++++++++++++++++++++++++++++++-- 1 files changed, 53 insertions(+), 4 deletions(-)

diff --git a/pep-0201.txt b/pep-0201.txt --- a/pep-0201.txt +++ b/pep-0201.txt @@ -172,6 +172,26 @@ >>> map(None, a, b, c, d) [(1, 5, 9, 12), (2, 6, 10, 13), (3, 7, 11, None), (4, 8, None, None)]

Reference Implementation @@ -195,6 +215,8 @@ self.__seqlen = len(args)

     def __getitem__(self, i):

@@ -218,6 +240,8 @@ slen = len(s) if shortest < 0 or slen < shortest: shortest = slen

@@ -226,6 +250,30 @@ longest = slen return longest

@@ -335,7 +383,8 @@

   3) Raises TypeError

@@ -345,9 +394,9 @@ with the zip compression algorithm. Other suggestions include (but are not limited to!): marry, weave, parallel, lace, braid, interlace, permute, furl, tuples, lists, stitch, collate, knit,

-- Repository URL: http://hg.python.org/peps



More information about the Python-checkins mailing list