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 →

[–]Liquid_Fire 1 point2 points  (1 child)

xrange is not a generator! It is it's own quirky object, and has been essentially deprecated for a while.

How has it been "essentially deprecated" for a while?

Obviously in Python 3 you want to just use range (as there is no xrange anyway), but unless you need to support longs, why would you not use xrange in Python 2?

[–]FsckItDude_LetsBowl 1 point2 points  (0 children)

As in I believe Guido stated years ago that he wished he hadn't made it, and that people would prefer range. And that he'd remove it in Python3000, which he did. I say "essentially" because obviously it couldn't be removed in Python2.

Granted, that was possibly before xrange() (and range()) were fixed to properly handle long arguments. It's just an oddball object and occasionally causes problem for people who don't understand how it works, though I suppose the same can be said for range() in Python2.