[docs] Bug in part 5 of the Python 3 tutorial

Eli Bendersky eliben at gmail.com
Tue Jul 31 06:56:38 CEST 2012


> In the Python 3 tutorial about data structures, in the section about nested
> list comprehensions
> (http://docs.python.org/py3k/tutorial/datastructures.html#nested-list-comprehensions);
> the zip function is described differently than it works in my installation
> (Ubuntu 12.04). I'm fairly new to Python so the issue is probably described
> best using an example:
>
>     $ python3
>     Python 3.2.3 (default, May  3 2012, 15:51:42)
>     [GCC 4.6.3] on linux2
>     Type "help", "copyright", "credits" or "license" for more information.
>     >>> matrix = [
>     ...     [1, 2, 3, 4],
>     ...     [5, 6, 7, 8],
>     ...     [9, 10, 11, 12],
>     ... ]
>     >>> zip(*matrix)
>     <zip object at 0x1053098>
>
> However, in the tutorial the zip function returns a list of tuplets like
> this:
>
>     >>> zip(*matrix)
>     [(1, 5, 9), (2, 6, 10), (3, 7, 11), (4, 8, 12)]
>
> In order to get that result, I have to do this in my installation:
>
>     >>> list(zip(*matrix))
>     [(1, 5, 9), (2, 6, 10), (3, 7, 11), (4, 8, 12)]
>

Without looking too deep into it, it appears that the example has not
been ported to Python 3. Please open an issue in the bug tracker for
this.

Eli


More information about the docs mailing list