Path: csiph.com!goblin1!goblin.stu.neva.ru!uio.no!news.tele.dk!news.tele.dk!small.news.tele.dk!newsgate.cistron.nl!newsgate.news.xs4all.nl!nzpost1.xs4all.net!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; '16,': 0.03; 'subject:Python': 0.05; 'cc:addr:python-list': 0.09; 'argument,': 0.09; 'python': 0.10; 'syntax': 0.13; 'def': 0.13; 'wed,': 0.15; 'expression.': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'objects).': 0.16; 'omitting': 0.16; 'parentheses': 0.16; 'wrote:': 0.16; '2015': 0.20; 'cc:2**0': 0.20; 'cc:addr:python.org': 0.20; '(the': 0.22; 'sep': 0.22; 'am,': 0.23; 'consistent': 0.23; 'header:In-Reply-To:1': 0.24; 'skip:# 10': 0.27; 'message-id:@mail.gmail.com': 0.27; 'object,': 0.27; 'function': 0.28; 'cases.': 0.29; "i'm": 0.30; 'print': 0.30; 'classes': 0.30; 'that.': 0.30; 'call.': 0.30; 'language.': 0.32; 'problem': 0.33; "d'aprano": 0.33; 'steven': 0.33; 'received:google.com': 0.35; "isn't": 0.35; 'but': 0.36; 'subject:: ': 0.37; 'end': 0.39; 'where': 0.40; 'course': 0.62; 'here': 0.66; 'special': 0.73; 'chrisa': 0.84; 'to:none': 0.91; 'horror': 0.91 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=hs3X1QzdANLrWaYk5dsWFQUEm2J5M0Dz2E7AjQq3jNs=; b=MBSxH1w5UWSyugF0Zmi7nAd21puVLhHqbOh5IBX2rfXJABDjxoGou/uRR2kcqCvn6T wZJFb7Rzt7sVKqls4IMeICcMuimXzS6IguSUnx0ZC3wrOYTQJD7Rg/Kmrl6XqF4bTso7 Sh83r0DeL3rGQ/31u0a+evStKq+n+eqjhy0UVRRokfr11NO0eMV6l29GjibWIdVgLwk+ zZ3RFSCVDsgYXTeYt4BHiqC7kBv/89HxWzkeJ0pDhEFa4APETZVHaKuBHJr6xHDsW7Ux aaD3lHK+u5cWkx+h1fi3vNgbpUPsM48dze1ECUxPXPbYX26YdRiKJ171ZpqUeDTJIHCD DVYg== MIME-Version: 1.0 X-Received: by 10.107.33.81 with SMTP id h78mr7362104ioh.19.1442368716420; Tue, 15 Sep 2015 18:58:36 -0700 (PDT) In-Reply-To: <55f8c3d0$0$1672$c3e8da3$5496439d@news.astraweb.com> References: <86fa425b-d660-45ba-b0f7-3beebdec8e14@googlegroups.com> <55EE9EEC.1060907@rece.vub.ac.be> <55EEDD37.5090602@gmx.com> <55f072aa$0$1669$c3e8da3$5496439d@news.astraweb.com> <55F130CE.5060203@rece.vub.ac.be> <55F191CD.8040901@gmail.com> <55f3a08d$0$1674$c3e8da3$5496439d@news.astraweb.com> <55f8c248$0$1649$c3e8da3$5496439d@news.astraweb.com> <55f8c3d0$0$1672$c3e8da3$5496439d@news.astraweb.com> Date: Wed, 16 Sep 2015 11:58:36 +1000 Subject: Re: Python handles globals badly. 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: 44 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1442368719 news.xs4all.nl 23869 [2001:888:2000:d::a6]:58268 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:96655 On Wed, Sep 16, 2015 at 11:20 AM, Steven D'Aprano wrote: > On Wed, 16 Sep 2015 11:13 am, Steven D'Aprano wrote: > >> Python is a remarkably clean and consistent language. There's only one >> kind of value (the object -- everything is an object, even classes are >> objects). The syntax isn't full of special cases. For example, there's >> nothing like this horror from Ruby: >> >> #!/usr/bin/ruby >> def a(x=4) >> x+2 >> end >> >> b = 1 >> print "a + b => ", (a + b), "\n" >> print "a+b => ", (a+b), "\n" >> print "a+ b => ", (a+ b), "\n" >> print "a +b => ", (a +b), "\n" >> >> >> which prints: >> >> 7 >> 7 >> 7 >> 3 > > > Of course it doesn't. It prints: > > a + b => 7 > a+b => 7 > a+ b => 7 > a +b => 3 > > > Sorry about that. I'm not a Rubyist, but my reading of this is that the last one is calling a with +b as its argument, where all the others are calling a with no argument, and then using the result in an expression. ISTM the problem here is omitting the parentheses on a function call. ChrisA