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/006933.html below:

[Python-Dev] PEP 201 - Parallel iteration

[Python-Dev] PEP 201 - Parallel iterationBarry A. Warsaw bwarsaw@beopen.com
Tue, 18 Jul 2000 23:58:28 -0400 (EDT)
>>>>> "KM" == Ken Manheimer <klm@digicool.com> writes:

    KM> Evan Simpson (a colleague here at digicool, who'd be a good
    KM> addition to python-dev) noticed that unzip is unnecessary -
    KM> zip is its own inverse.

Only if the sequences are of the same length.  I've added this to the
PEP, using the extended call syntax.

    Note that when the sequences are of the same length, zip() is
    reversible:

    >>> a = (1, 2, 3)
    >>> b = (4, 5, 6)
    >>> x = zip(a, b)
    >>> y = zip(*x) # alternatively, apply(zip, x)
    >>> z = zip(*y) # alternatively, apply(zip, y)
    >>> x
    [(1, 4), (2, 5), (3, 6)]
    >>> y
    [(1, 2, 3), (4, 5, 6)]
    >>> z
    [(1, 4), (2, 5), (3, 6)]
    >>> x == z
    1

    It is not possible to reverse zip this way when the sequences are
    not all the same length.

-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