Path: csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail From: Terry Reedy Newsgroups: comp.lang.python Subject: Re: Guido on python3 for beginners Date: Thu, 18 Feb 2016 03:40:07 -0500 Lines: 99 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; format=flowed Content-Transfer-Encoding: 7bit X-Trace: news.uni-berlin.de 9MGfyLwtT+Wt/jTl/VfM+Qhl6ArkIsqyiy9mXmGfvq9A== 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; 'builtin': 0.07; 'classes.': 0.07; 'difference,': 0.07; 'scripts': 0.09; '"python"': 0.09; 'bytes,': 0.09; 'default)': 0.09; 'integers': 0.09; 'part,': 0.09; 'php,': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'str,': 0.09; 'term,': 0.09; 'unicode,': 0.09; 'worse': 0.09; 'python': 0.10; 'jan': 0.11; 'language,': 0.11; '2.7': 0.13; 'exception': 0.13; 'question.': 0.13; 'syntax': 0.13; 'interpreter': 0.15; 'thu,': 0.15; "'c'": 0.16; '(str,': 0.16; '2016': 0.16; 'decent': 0.16; 'division,': 0.16; 'elsewhere.': 0.16; 'encodings': 0.16; "isn't.": 0.16; 'least.': 0.16; 'magic': 0.16; 'massively': 0.16; 'old-style': 0.16; 'overlaps': 0.16; 'parentheses': 0.16; 'printf()': 0.16; 'program"': 0.16; 'py3': 0.16; 'received:80.91.229.3': 0.16; 'received:io': 0.16; 'received:plane.gmane.org': 0.16; 'received:psf.io': 0.16; 'reedy': 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; '2.x': 0.22; '3.x': 0.22; "aren't": 0.22; 'arguments': 0.22; 'either.': 0.22; 'features,': 0.22; 'suppose': 0.22; 'text,': 0.22; 'tkinter': 0.22; 'trying': 0.22; 'am,': 0.23; 'feb': 0.23; 'absolute': 0.23; 'errors': 0.23; '(most': 0.24; 'patch': 0.24; 'header:In-Reply-To:1': 0.24; 'all.': 0.24; 'header :User-Agent:1': 0.26; "doesn't": 0.26; 'header:X-Complaints-To:1': 0.26; 'sense': 0.26; 'chris': 0.26; 'mostly': 0.27; 'question': 0.27; 'correct': 0.28; 'function': 0.28; 'this.': 0.28; 'ahead.': 0.29; 'curve': 0.29; 'division': 0.29; 'does,': 0.29; 'forces': 0.29; 'i/o': 0.29; 'invoke': 0.29; 'mind,': 0.29; 'windows,': 0.29; 'yields': 0.29; 'print': 0.30; 'classes': 0.30; 'work.': 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; 'open': 0.33; 'languages': 0.34; 'gives': 0.35; 'clear': 0.35; 'fresh': 0.35; 'unicode': 0.35; 'something': 0.35; "isn't": 0.35; 'but': 0.36; 'list,': 0.36; 'should': 0.36; 'instead': 0.36; 'there': 0.36; 'basic': 0.36; 'alone': 0.36; 'keyword': 0.36; 'received:71': 0.36; 'between': 0.65; 'soon': 0.65; 'believe': 0.66; 'benefit': 0.66; 'numerous': 0.66; "they're": 0.66; 'life': 0.67; 'biggest': 0.67; '11.': 0.70; 'levels': 0.70; 'acts': 0.72; 'advantages': 0.72; 'introduce': 0.79; 'discovered': 0.83; '(also,': 0.84; 'ease.': 0.84; 'learn.': 0.84; "there'll": 0.84; 'wins': 0.84; 'received:fios.verizon.net': 0.91; 'write()': 0.91; 'tough': 0.95 X-Injected-Via-Gmane: http://gmane.org/ X-Gmane-NNTP-Posting-Host: pool-71-185-227-36.phlapa.fios.verizon.net User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.6.0 In-Reply-To: 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:103096 On 2/18/2016 2:27 AM, 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. 8. 2.x has two subtlely different types of classes. The 2.x docs do not document the type of builtin and stdlib classes. I discovered that tkinter classes are still old-style in 2.7 when I backported a patch from 3.x to 2.7 and it mysteriously did not work. Py 3 wins here. To me, this alone makes 2.x a bad choice for most beginners. 9. Two integer classes and the nuisance of 'L' suffix. Py 3 wins for beginners, at least. (Mentioned by Inaki). 10. Two except-clause syntaxes in 2.7, just one in 3.x. -1 syntax is +1 vote for 3.x 11. To test is something is text, isinstance s, c), where 'c' is one of str, bytes, unicode, basestring, (bytes, unicode), (str, unicode). +1 for 3.x. 12. 2.7 has two different open' functions, open and io.open. In 3.x these are the same opjects. I believe there are other 3.x backports like this. 13. 2.7 has two ways to apply arguments to functions: apply and *args. 3.x only has the latter. To my mind, the numerous duplications and overlaps in 2.7 that are gone in 3.x make 2.7 the worse version ever for beginners. -- Terry Jan Reedy