Path: csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail From: Chris Angelico Newsgroups: comp.lang.python Subject: Re: Guido on python3 for beginners Date: Thu, 18 Feb 2016 18:27:59 +1100 Lines: 69 Message-ID: References: <48762040-a7e0-434c-92e8-8a0969210e5b@googlegroups.com> <5d31dd14-1a60-4f80-8889-d0616f404c70@googlegroups.com> <4e902c58-3370-4adf-905d-74630a6eea90@googlegroups.com> <60036746-78f7-4f05-a6d8-04e88b09c00f@googlegroups.com> <032f0f66-34df-4325-98e0-1127025d2a94@googlegroups.com> <31a618b2-a407-4723-9a4f-9b756fc93b0b@googlegroups.com> <0a920e92-5d31-4866-815b-cae7e201e4d8@googlegroups.com> <56c568f2$0$2832$c3e8da3$76491128@news.astraweb.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-Trace: news.uni-berlin.de tLrI2Qz1pO6yfCrP460aCQLDm6omTG238SvI3q1kUOhw== Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.000 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'float': 0.05; '(unicode': 0.07; 'difference,': 0.07; 'cc:addr:python-list': 0.09; 'scripts': 0.09; '"python"': 0.09; 'default)': 0.09; 'integers': 0.09; 'part,': 0.09; 'php,': 0.09; 'term,': 0.09; 'python': 0.10; 'language,': 0.11; 'exception': 0.13; 'question.': 0.13; 'syntax': 0.13; 'interpreter': 0.15; 'thu,': 0.15; '2016': 0.16; 'decent': 0.16; 'division,': 0.16; 'elsewhere.': 0.16; 'encodings': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; "isn't.": 0.16; 'magic': 0.16; 'massively': 0.16; 'parentheses': 0.16; 'printf()': 0.16; 'program"': 0.16; 'py3': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'subject:python3': 0.16; 'usage,': 0.16; 'wrote:': 0.16; 'later': 0.16; 'memory': 0.17; 'integer': 0.18; 'language': 0.19; 'changes': 0.20; 'cc:2**0': 0.20; 'cc:addr:python.org': 0.20; "aren't": 0.22; 'arguments': 0.22; 'either.': 0.22; 'features,': 0.22; 'suppose': 0.22; 'text,': 0.22; 'trying': 0.22; 'feb': 0.23; 'absolute': 0.23; 'errors': 0.23; '(most': 0.24; 'header:In-Reply-To:1': 0.24; 'all.': 0.24; "doesn't": 0.26; 'sense': 0.26; 'mostly': 0.27; 'question': 0.27; 'message-id:@mail.gmail.com': 0.27; 'correct': 0.28; 'function': 0.28; 'ahead.': 0.29; 'curve': 0.29; 'division': 0.29; 'does,': 0.29; 'forces': 0.29; 'i/o': 0.29; 'invoke': 0.29; 'windows,': 0.29; 'yields': 0.29; 'print': 0.30; 'call.': 0.30; 'users.': 0.31; 'aside': 0.32; 'generally': 0.32; 'statement': 0.32; 'maybe': 0.33; 'problem': 0.33; "d'aprano": 0.33; 'interaction': 0.33; 'programming,': 0.33; 'steven': 0.33; 'languages': 0.34; 'gives': 0.35; 'received:google.com': 0.35; 'clear': 0.35; 'fresh': 0.35; 'unicode': 0.35; "isn't": 0.35; 'but': 0.36; 'list,': 0.36; 'should': 0.36; 'instead': 0.36; 'there': 0.36; 'received:209.85': 0.36; 'basic': 0.36; 'keyword': 0.36; 'pm,': 0.36; 'subject:: ': 0.37; 'really': 0.37; 'two': 0.37; 'received:209.85.213': 0.37; 'things': 0.38; 'itself': 0.38; "won't": 0.38; 'version': 0.38; 'received:209': 0.38; 'building': 0.38; 'someone': 0.38; 'files': 0.38; 'speak': 0.38; 'system.': 0.39; 'easily': 0.39; 'where': 0.40; 'some': 0.40; 'term': 0.60; 'your': 0.60; 'back': 0.62; 'more': 0.63; 'different': 0.63; 'information': 0.63; 'times': 0.63; 'between': 0.65; 'soon': 0.65; 'benefit': 0.66; "they're": 0.66; 'life': 0.67; 'biggest': 0.67; 'levels': 0.70; 'acts': 0.72; 'advantages': 0.72; 'introduce': 0.79; '(also,': 0.84; 'chrisa': 0.84; 'ease.': 0.84; 'learn.': 0.84; "there'll": 0.84; 'to:none': 0.91; 'write()': 0.91; 'tough': 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=GoB4I3t4Yj40Cj04XrmXBlCYCtbjmXj4RgJyZYggl9k=; b=PDuxmbCh49gwg1rOEw9sqCF7Lqg0DCfPB5mwDEhkApNDZM6EWsB09KDi6vEZqMRFHu qUPNcwnf1siOtiPNhuMRzXB6g2+C6yzJA9Ki4Pg/EqmevGm6fIfii9im8B5N/abgfRT2 fiFVC7vQqlb+aYHhvXuAd7zNcGal/TkXw/eNb0ZvbupSFk2BWk+1I3VPOjqcl6yOu1z+ 1Cdf5Y1301Ay1JxKCgHXGIgLapp+1OmJxjv3iQpFgnYJr8+w+9SNLbXM4eXSh7K3ysW4 uRP4ZXQsT7E19pAaXEKu76pofT4M5y+LG5L8mPSXXus7xUkPjtWbKFFaqMuCtosdrgsB fqBg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:date :message-id:subject:from:cc:content-type; bh=GoB4I3t4Yj40Cj04XrmXBlCYCtbjmXj4RgJyZYggl9k=; b=iXffqcBk5geaDrU/c7azi3Y6RDJHYuK9d5XNqnTTir4FozXhF5XqcdvXndFkqTkXre DfsqgfBfvEtCl0LLSkkvcRekHICOtFxLsD8YYGJF7al04hoosasxOJ5mOsq3VfMXgaph ZMuPelZ8EpIMckkxIrP1mYSTor6R97u6tWwpliUGB7A96jhv5eGdxAIXirjKu4Rxqky6 hkmta5GislKtNsFyFy4a7uYHNxhSKo94WVpNfKD0s0LMKRrwp+CUMxPrrIwrFIwoGBSQ OrtuU/zZo4J+9S9dcEANsZStIanKOtqgTlTaal1J34NKRl2I24X9Gl7hwYChnJ25Y33S qX5Q== X-Gm-Message-State: AG10YOQH2xE2zPpXrOl9IdZTscvz7wzb3eg5vjqk02P1D/rGLiKYcJ8hjiHEVNvqsQYjUU70AyjCqYGDWaUd0g== X-Received: by 10.50.176.195 with SMTP id ck3mr1913424igc.94.1455780479145; Wed, 17 Feb 2016 23:27:59 -0800 (PST) In-Reply-To: <56c568f2$0$2832$c3e8da3$76491128@news.astraweb.com> X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.21rc2 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Xref: csiph.com comp.lang.python:103092 On Thu, Feb 18, 2016 at 5:47 PM, Steven D'Aprano wrote: > There are more features in Python 3, so in that trivial sense of "more to > learn", I suppose that it is objectively correct that it is harder to learn > than Python 2. But I don't think the learning curve is any steeper. If > anything, the learning curve is ever-so-slightly less steep. Let's see... changes in Py3. 1) Division of two integers now yields a float instead of flooring. For someone fresh to programming, that's a Py3 advantage, although it can cause surprises elsewhere. But since 1.0==1, it's not going to be a problem for a new programmer. Advantage: Py3. 2) Strings are Unicode text, and files etc may need to have their encodings declared. Definitely causes some issues in ASCII-only situations, where a lot of other languages (notably including PHP, for the people building web sites) let you be sloppy. Advantage: Py3 if you speak any language other than English; otherwise Py2 in the very short term, neither in the medium term, and most definitely Py3 in the long term (no more "funny characters break my program" errors long after deployment). 3) Laziness. When you explain to someone what the range() function does, Py2 makes a list, but Py3 makes... a range. It doesn't really answer the question at all. When you ask Py2 for a dictionary's keys/values, you get a list; Py3 gives you a thing that mostly acts like a list, only it isn't. If you map a function over a list, you get back a lazy thing that will eventually call that function. Py2 often has less levels of indirection, ergo less things to try to explain. Advantage: Py2; the benefits (lower memory usage, etc) aren't significant to new users. 4) Exception chaining. You get more information when errors cascade. Advantage: Py3, easily and without any question. 5) print statement/function. Py3 forces you to put parentheses on it, which is no different from C's printf() or Pike's write() or any number of other languages where console I/O needs no language support. Maybe a tiny TINY advantage to Py2 in the short term, but as soon as you introduce the less basic features, keyword arguments are way better than the magic syntax the statement needs. (Also, trying to explain the interaction between the print statement's "soft space" and other console I/O is not easy.) By the time you've really learned the language, the advantage belongs to Py3. 6) The fact that the name "python" may not invoke the interpreter you want. Advantage: Py2, if any; there'll be times when they're on par, but Py3 never comes out ahead. 7) Whether or not the interpreter comes pre-installed on your system. As of a few years ago, that was a clear advantage to Py2 (most systems would ship with both, or neither, or Py2 only), but that's shifting. It's only a small difference, though; on Windows, you generally get nothing, and on any system with a decent package manager, you should be able to request either version with ease. It's actually a pretty tough call. Most of the Py3 advantages aren't for the absolute beginner; it's not easier to write "Hello, world" in Py3, and aside from the change to integer division, most of the changes won't benefit small-to-medium scripts either. The biggest advantage (Unicode by default) really only shows itself by sparing you hassles later on - it's not going to make your life easier in the short term, ergo it's not going to make the language easier to learn. Py3 isn't so much easier as _better_. There are specific situations where it's massively better, but for the most part, they're about on par. ChrisA