On Sun, May 3, 2015 at 9:15 PM, Steven D'Aprano
<steve+comp.lang.pyt...@pearwood.info> wrote:
> Or if you prefer:
>
> try:
>     range = xrange
> except NameError:
>     pass
>
> and just use range.

I prefer this idiom, on the basis that code should be written for the
more recent version, and have minimal code to support older versions.
Then when you drop support for the older versions, all you have to do
is delete a bit at the top. The same principle applies to the
__future__ import system - you can declare that your Python 2.5 code
is able to use the 'with' statement, but you can't (and shouldn't)
make your 2.6+ code use 'with' as a name.

ChrisA
-- 
https://mail.python.org/mailman/listinfo/python-list

Reply via email to