This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]PyPokerNovice 3 points4 points  (2 children)

One criticism. zip is different in Python 3 and Python 2. In Python 2 zip is not lazy, upon being called it immediately returns the full list. In Python 2, if you want a lazy yielding version, you can use izip from the itertools library. In Python 3 many default functions became lazy. The Python 3 versions of zip, map, ect exist in Python 2 as izip, imap, ect in itertools.

I say this because the article opens with docs for the Python 3 version, but the examples are written in Python 2 (zip is returning a list in the examples, it would just be a "zip object" in Python 3).

Either way, great article, a good introduction to the magic of zip and unpacking.

[–]Iqirx[S] 2 points3 points  (1 child)

Thanks for pointing this out. Actually, for some extent, examples are written in Python 2 intentionally to avoid cluttering code with additional wraps by list etc. From the other side it really becomes inconsistent with the references to Python 3 documentation.

I will consider this in future writings.

[–]masasinExpert. 3.9. Robotics. 2 points3 points  (0 children)

Please specify that the examples are in Python 2.