Path: csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail From: INADA Naoki Newsgroups: comp.lang.python Subject: Re: Guido on python3 for beginners Date: Thu, 18 Feb 2016 17:00:32 +0900 Lines: 93 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 GUHEAxsSAWtwb1y+YOBgyQuT2wPpIUtrHg0Q8Gd8imNA== 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; 'received:209.85.223': 0.03; 'float': 0.05; '(unicode': 0.07; 'difference,': 0.07; 'strings.': 0.07; 'scripts': 0.09; '"python"': 0.09; 'default)': 0.09; 'integers': 0.09; 'non-ascii': 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; "isn't.": 0.16; 'log.': 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; 'unicodeerror': 0.16; 'usage,': 0.16; 'wrote:': 0.16; 'later': 0.16; 'memory': 0.17; 'string': 0.17; 'integer': 0.18; 'skip:` 10': 0.18; '>': 0.18; 'email addr:gmail.com>': 0.18; 'language': 0.19; 'changes': 0.20; 'to:name:python-list@python.org': 0.20; "aren't": 0.22; 'arguments': 0.22; 'ascii': 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; 'chris': 0.26; 'logging': 0.27; '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; 'url:mailman': 0.30; 'code': 0.30; 'call.': 0.30; 'users.': 0.31; 'fixed': 0.31; 'non': 0.32; 'aside': 0.32; 'generally': 0.32; 'statement': 0.32; 'maybe': 0.33; 'problem': 0.33; 'url:python': 0.33; "d'aprano": 0.33; 'interaction': 0.33; 'programming,': 0.33; 'steven': 0.33; 'url:listinfo': 0.34; '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; 'url:org': 0.36; 'received:209.85': 0.36; 'basic': 0.36; 'keyword': 0.36; 'to:addr :python-list': 0.36; 'pm,': 0.36; 'subject:: ': 0.37; 'really': 0.37; 'two': 0.37; 'skip:& 10': 0.37; 'things': 0.38; 'itself': 0.38; "won't": 0.38; 'version': 0.38; 'received:209': 0.38; 'building': 0.38; '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; 'teach': 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; '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:from:date:message-id:subject:to :content-type; bh=PmauYROtLcxe0DB1J3vfGDvxIUYrYNQbY9/6IcutYX8=; b=0c9uc+VMyZiTIy4oCtVxeOOrvuVcS6N1y2v4i7xomUpPhWFG/aOYNNkXcMhRXSZDyL BHS2MfLKrfBhQefo5ZPNjuuUPur8qGbyW+T4hb0SmmigIsTO6cjBhinm9JK+wT3jttXw tXLs6fMuHTzaJkthXA81y7vl7y0KcobOt7OwWna65qefbNp0tKyvNm0Lu7akEEqVDual 5EG4/0x7DRbUSrLdbRS3n5RUB+iSutUWHbrJeaSUKfvOuR4fvXeaKLz0pLRVgy1A49mZ 4v+QYlMB5UCGNP6HfwrTYtZWXQwhO5o5mfWcsHPncjiH6yClh18XH8QotNz//ZfEw+X7 kQ2g== 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:from:date :message-id:subject:to:content-type; bh=PmauYROtLcxe0DB1J3vfGDvxIUYrYNQbY9/6IcutYX8=; b=KOlQ+jnNbuDRwdJ7QrNPshO3tZkshH9TT7Y5d3KnfLxvjUgE3IB1UQt+Q/ktu5So0j jcC8EbXR0wwogV+ENKdPOYnSDN5RDKInapQNRDj1ANUUMR/a6Ox1x1rsm6jRDVf3ot2M NDIW+fTdwbYT8qvjn2hTvJATLIM3VW9B5dMeEMOHqx675tJSxNLdjS33b4a3HqHhvN8I SVTTnbD8BXznL3LOvJKGh98YqhxLY16HSvcGQrYSYHdP+mCc0uf9GDNf2d/t8s0ikFUR ue5ke/70/8GrgH3t1GZJIDYJzXczfE1X/cpkRWH21pMfpdwi3OHziLwkGmvuGR1pfuTc D6Xw== X-Gm-Message-State: AG10YOQs60BUQUV/HjQ9ptQfHE/0PspccGyUIyT4PBGlANRLKzZh0gCK84lCih2OgEaKP7u/dGNI4hd8J9Gy1A== X-Received: by 10.107.10.101 with SMTP id u98mr7980402ioi.60.1455782451819; Thu, 18 Feb 2016 00:00:51 -0800 (PST) In-Reply-To: X-Content-Filtered-By: Mailman/MimeDel 2.1.21rc2 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:103094 In Python 3, I don't required to teach followings to newbies. 1. Don't do `class Foo:`, do `class Foo(object):`. 2. Don't do `isinstance(x, int)`, do `isinstance(x, (int, long))`. 3. Don't return non-ASCII string from `__repr__`, otherwise UnicodeError happens in logging and you will lost your important log. 4. Use %r instead of %s in logging to avoid UnicodeError when __str__ returns non ASCII strings. I think there are many pitfalls fixed in Python 3 other than above. Python 3 is far easier to teach and review code than Python 2. On Thu, Feb 18, 2016 at 4:27 PM, Chris Angelico wrote: > 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 > -- > https://mail.python.org/mailman/listinfo/python-list > -- INADA Naoki