@ ΤΖΩΤΖΙΟΥ: true, but this does not have the benefit you may think. range() in pre-3.0 pythons pulls all the data at once. xrange() acts like a generator, pulling only one item at a time. But if you are going to reverse a sequence, you need all the data at once, so reversed(range()) and reversed(xrange()) will work in the same way: they'll each have all the data pulled before it is reversed.
–
hughdbrownApr 13 '10 at 15:19

2

@hughdbrown: it does have the benefit you think I might be thinking. Check the dir(xrange) output and note the __reversed__ special method.
–
tzotApr 13 '10 at 22:07

-1: This has one too few items. It incorrectly omits 0. Separately, in python3 it fails because n/2 generates a float (TypeError: 'float' object cannot be interpreted as an integer). But maybe that's why you called out that it is for python 2.x.
–
hughdbrownFeb 20 '13 at 22:58