Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.albasani.net!rt.uk.eu.org!newsfeed.xs4all.nl!newsfeed3.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.002 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'subject:Python': 0.06; 'float': 0.07; 'stops': 0.07; 'string': 0.09; 'integers': 0.09; 'line:': 0.09; 'migration': 0.09; 'pep': 0.09; 'subject:Why': 0.09; 'cc:addr:python-list': 0.11; 'python': 0.11; 'bug': 0.12; '"python"': 0.16; '"python",': 0.16; '(floor': 0.16; '__future__': 0.16; 'behave': 0.16; 'bytes;': 0.16; 'fine.': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'integer.': 0.16; 'quoted': 0.16; 'ways:': 0.16; 'sat,': 0.16; 'so.': 0.16; 'language': 0.16; 'wrote:': 0.18; 'basically': 0.19; "hasn't": 0.19; 'typing': 0.19; 'import': 0.22; 'issue.': 0.22; 'cc:addr:python.org': 0.22; 'adds': 0.24; 'byte': 0.24; 'bytes': 0.24; 'features,': 0.24; 'integer': 0.24; 'text,': 0.24; 'unicode': 0.24; 'paul': 0.24; 'regardless': 0.24; 'versions': 0.24; 'cc:2**0': 0.24; "i've": 0.25; '(see': 0.26; 'possibly': 0.26; 'least': 0.26; 'header:In-Reply-To:1': 0.27; 'function': 0.29; 'statement': 0.30; 'strongly': 0.30; 'then.': 0.30; 'message-id:@mail.gmail.com': 0.30; "i'm": 0.30; 'work.': 0.31; 'code': 0.31; '3.2': 0.31; '3.x': 0.31; 'becoming': 0.31; 'default,': 0.31; 'division': 0.31; 'universal': 0.31; 'probably': 0.32; 'critical': 0.32; 'run': 0.32; 'text': 0.33; 'linux': 0.33; "i'd": 0.34; 'something': 0.35; 'equal': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'version': 0.36; '2.6': 0.36; 'in.': 0.36; 'doing': 0.36; 'subject:?': 0.36; 'two': 0.37; 'project': 0.37; 'starting': 0.37; 'being': 0.38; 'minimum': 0.38; 'form,': 0.38; 'pm,': 0.38; 'that,': 0.38; 'little': 0.38; 'even': 0.60; 'skip:u 10': 0.60; 'eventually': 0.60; 'break': 0.61; 'new': 0.61; 'today,': 0.61; 'course': 0.61; "you're": 0.61; 'choose': 0.64; 'more': 0.64; 'kept': 0.65; 'situation': 0.65; 'within': 0.65; 'between': 0.67; 'default': 0.69; 'yourself': 0.78; 'divide': 0.84; 'absolutely': 0.87; 'bless': 0.91; 'mistake': 0.91; 'to:none': 0.92; 'tomorrow': 0.95 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=OownMmk0YignGAg+3ltnYquPK+MfC1UMN3TIfc8mZ5Q=; b=NEETws7vLTNG6vXzuElsyJFbr0gWAZJf02CR5iO8HCO313ZMPhXFA4fUzuEW0JB479 Diqoei/FXDBRp37YMRocqq3iuOH2V2sHbM6T0NLBCWmskTMgkftxurcvJ/3jq8ozTBYa E+wMRy/xLFYqb2OsDqN9qb8sm32FZH/shJoBU+SlXegIHYroL/3q7xfY4d5mMbwbwQII kWZ2S73oatoU4nCmgfWnpEZlNw6GggDtC2xcui5HUsz4KFPUgm1Zol6kXrIDDMNbA1w8 6iwFG6q6de83Am5Qx7bybXdfMT6rfAr0ZEjLXbVL7AQMZ/iJZeJGW+hQWXiddNa/miFe 1k6g== MIME-Version: 1.0 X-Received: by 10.58.202.133 with SMTP id ki5mr17637915vec.19.1397892876353; Sat, 19 Apr 2014 00:34:36 -0700 (PDT) In-Reply-To: <7x8ur1esa5.fsf@ruckus.brouhaha.com> References: <7x8ur1esa5.fsf@ruckus.brouhaha.com> Date: Sat, 19 Apr 2014 17:34:36 +1000 Subject: Re: Why Python 3? 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.15 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: 48 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1397892885 news.xs4all.nl 2968 [2001:888:2000:d::a6]:58282 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:70372 On Sat, Apr 19, 2014 at 4:40 PM, Paul Rubin wrote: > If you're starting a new project and you get to choose between 2 and 3, > other things equal I'd say use 3. I've kept using 2 basically because > it's the path of least resistance. I'm somewhat following the 3 > situation and of course I'd use 3 if I were doing something that > benefited from it, but so far it hasn't been an issue. > > Eventually the main Linux distros will include 3 instead of 2 by > default, and we'll probably see more migration then. Right now I type > "python" and get 2, so I use it. Several of the main distros are already including Python 3 by default (eg Ubuntu), but when you type "python", you still get Python 2, for reasons of compatibility. (See PEP 394.) As long as you set your shebang to say python3, it'll work just fine. I strongly recommend going for Python 3 unless something actually stops you from doing so. If you absolutely must use Python 2, try to aim for a minimum of 2.6 or 2.7, and start your program with this line: from __future__ import print_function, unicode_literals, division That'll make Python 2.6/2.7 behave like Python 3.x in three ways: firstly, "print" will be a function instead of a statement (and it's more powerful than the statement form, as well as being more flexible); secondly, quoted strings will be Unicode strings, not byte strings (that'll help you to start thinking about what's bytes and what's text, which is an important distinction in Python 3); and thirdly, though less important than the others, the division of two integers will result in a floating point, not an integer. I personally think the last one was a mistake on Python 3's part (why bless float specifically? what if you're working with integers and decimal.Decimals?), but if you're going to move to Python 3, you may as well have your code start working that way, so you get used to typing // to divide integers and get an integer (floor division). But if you possibly can, aim for Python 3. Every new version adds features, and new versions within the 3.x line break very little (generally only what would have been working with a bug anyway, like narrow Unicode builds of 3.2 becoming universal on 3.3). If you aim for 3.2 today, and tomorrow try to run your code on 3.4, chances are it'll work. The main thing is, know what's a text string and what's a string of bytes; that's critical in 3.x, but not in 2.x. Force yourself to think about that, and your code will be more reliable - regardless of even what language you write it in. ChrisA