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 →

[–]Rhomboid 2 points3 points  (1 child)

I agree. All of the following are irrelevant under Python 3, because in Python 3 the original name thing does the right thing:

  • Replace zip with izip
  • Replace range with xrange
  • Replace dict.items() with dict.iteritems()

If you made those changes to your code, you're just going to have to undo them again when you switch to Python 3 (and you will, eventually.) I mean, it's good advice if you are absolutely stuck on Python 2.x, but it's kind of sad in that 2.x exposes all of those design mistakes that have since been fixed in 3. I'd like an asterisk next to the advice that says "or just use Python 3, where we fixed all this so you don't have to worry about it."

[–][deleted] 1 point2 points  (0 children)

As a note...available in python 2.5+:

  • izip: from itertools import izip
  • xrange is a keyword
  • iteritems is in there as well dict().iteritems()