Path: csiph.com!usenet.pasdenom.info!news.redatomik.org!newsfeed.xs4all.nl!newsfeed2a.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.012 X-Spam-Evidence: '*H*': 0.98; '*S*': 0.00; 'versions,': 0.07; 'versions.': 0.07; 'try:': 0.09; 'cc:addr:python-list': 0.11; 'python': 0.11; '9:15': 0.16; '__future__': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'nameerror:': 0.16; 'range.': 0.16; 'xrange': 0.16; 'applies': 0.16; 'wrote:': 0.18; 'bit': 0.19; 'written': 0.21; 'import': 0.22; 'cc:addr:python.org': 0.22; 'cc:2**0': 0.24; 'pass': 0.26; 'header:In-Reply-To:1': 0.27; 'message-id:@mail.gmail.com': 0.30; 'code': 0.31; "d'aprano": 0.31; 'steven': 0.31; 'minimal': 0.33; 'older': 0.33; "can't": 0.35; 'except': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'should': 0.36; 'version,': 0.38; 'pm,': 0.38; 'recent': 0.39; 'delete': 0.39; 'range': 0.61; 'more': 0.64; 'statement,': 0.68; "'with'": 0.84; '2015': 0.84; 'top.': 0.84; 'to:none': 0.92 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:cc :content-type; bh=e8jgO0olojZXLXGsTUE6d3jGqYBx8rjayi66bwpXYd4=; b=jUNvKi+HRr+BJjDAT0X7HVpDvvkzs+xBFArLY9vmfQEX1OaPAl0fAstiVyQT19qYby 73ARDkdsTadZ/8pex3vjdFdpaE8IWCvoR6y5F9RYF2YncMl6Lg9aghk4Tp/+donAhbkV aVmxaHBVCm80c37a6NoRRCpYyEbk/eJgkpCKc4awCNbFievVNkkNM458Oo8cjdCFlZnB SelzLmwBWrMmDananKEoLvC1WO7AposhzQscz0RKZBUoKjTuVWB40ir6PzfbXN8ZIoug voplCA+7PgObXVUPqpxD3H8EL7ln85uh6+3y+93AVbtXRu2FPwUUZd0PDOnVxL3ikmRi Bpgg== MIME-Version: 1.0 X-Received: by 10.43.39.1 with SMTP id tk1mr20959451icb.26.1430652561887; Sun, 03 May 2015 04:29:21 -0700 (PDT) In-Reply-To: <5546035d$0$13001$c3e8da3$5496439d@news.astraweb.com> References: <87k2wtvbx1.fsf@Equus.decebal.nl> <_M61x.477467$Ek.357048@fx07.am4> <5546035d$0$13001$c3e8da3$5496439d@news.astraweb.com> Date: Sun, 3 May 2015 21:29:21 +1000 Subject: Re: l = range(int(1E9)) From: Chris Angelico Cc: "python-list@python.org" Content-Type: text/plain; charset=UTF-8 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.20+ Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 20 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1430652565 news.xs4all.nl 2840 [2001:888:2000:d::a6]:54395 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:89862 On Sun, May 3, 2015 at 9:15 PM, Steven D'Aprano 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