A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2000-July/006930.html below:

[Python-Dev] PEP 201 - Parallel iteration

[Python-Dev] PEP 201 - Parallel iterationBarry A. Warsaw bwarsaw@beopen.com
Tue, 18 Jul 2000 23:42:53 -0400 (EDT)
>>>>> "Gordo" == Gordon McMillan <gmcm@hypernet.com> writes:

    Gordo> How about a fourth: zip(a) is the same as zip(a, []) ?

I don't like it.  The way I view zip() is that the length of the
elements returned by __getitem__() should always be equal to the
number of sequences passed in as parameters.  Thus it seems most
natural to me that

    >>> zip((1, 2, 3))
    [(1,), (2,), (3,)]
    >>> zip((1, 2, 3), pad=None)
    [(1,), (2,), (3,)]

When I talk about "special casing", there's two ways to look at it.
One possibility is that the implementation of zip has to explicitly
check that the number of sequences is 1 and then `do something
special' if so.  To support Gordon's proposal, or the
map()-equivalent, or the raise-an-exception proposal, that would be
the case.

The second possibility is that user code must `appear' to special case
the situation when the number of sequences is exactly 1.  I.e.

    >>> for (i,) in zip((1, 2, 3)):

instead of the more natural (because it's less to type and because of
the map() heritage):

    >>> for i in zip((1, 2, 3)):

The first example isn't really special casing though.  Personally, I
think this is going to come up so infrequently that it's not worth
it.

-Barry



RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4