A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2007-May/073032.html below:

[Python-Dev] best practices stdlib: purging xrange

[Python-Dev] best practices stdlib: purging xrange [Python-Dev] best practices stdlib: purging xrange"Martin v. Löwis" martin at v.loewis.de
Wed May 9 06:46:50 CEST 2007
> Just curious why 2to3 would not replace range() with list(range())?

In most usages of range(), using the 3.0 range() will work just as
well, and be more efficient.

If I wanted to write code that works in both versions (which I
understand is not the 2to3 objective), then I would use range().
If I worry about creating a list in 2.x, I would write

try:
  xrange
except NameError:
  xrange=range

at the top of the file.

Regards,
Martin
More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4