Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #101848
| Path | csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail |
|---|---|
| From | Chris Angelico <rosuav@gmail.com> |
| Newsgroups | comp.lang.python |
| Subject | Re: Keen eyes |
| Date | Sun, 17 Jan 2016 22:32:49 +1100 |
| Lines | 42 |
| Message-ID | <mailman.60.1453030378.15297.python-list@python.org> (permalink) |
| References | <d8e5eaf4-c59f-4635-8e73-f4a9a1a84877@googlegroups.com> <mailman.47.1452983435.15297.python-list@python.org> <7625bba2-5c2d-4d28-8b6a-30ec7b490089@googlegroups.com> <569b3e53$0$1615$c3e8da3$5496439d@news.astraweb.com> <CALwzid=8RSUQzsicoBac01LXDWs9BUoJ8atnfB4_ag7PmXXC+Q@mail.gmail.com> <mailman.56.1453019131.15297.python-list@python.org> <n7ft2d$f7b$1@dont-email.me> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=UTF-8 |
| X-Trace | news.uni-berlin.de O8045pxup2p58Evtb53GFQSyRl31z86rU1EN0H7Blqkw== |
| Return-Path | <rosuav@gmail.com> |
| 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; 'defaults': 0.05; 'compile-time': 0.07; 'cc:addr:python- list': 0.09; 'assigning': 0.09; 'global,': 0.09; 'whole.': 0.09; 'bug': 0.10; 'python': 0.10; 'jan': 0.11; 'variables': 0.15; '10:17': 0.16; '2016': 0.16; 'allocates': 0.16; 'declaration': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'globals.': 0.16; 'local.': 0.16; 'locally,': 0.16; 'occur.': 0.16; 'received:209.85.223.173': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'scope.': 0.16; 'scopes': 0.16; 'snippets': 0.16; 'wrote:': 0.16; "wouldn't": 0.16; 'found,': 0.18; 'variable': 0.18; 'language': 0.19; '>>>': 0.20; 'cc:2**0': 0.20; 'cc:addr:python.org': 0.20; 'implicit': 0.22; 'logical': 0.22; 'trying': 0.22; 'bit': 0.23; 'matching': 0.23; "python's": 0.23; 'header:In-Reply-To:1': 0.24; "i've": 0.25; 'sense': 0.26; 'chris': 0.26; 'message-id:@mail.gmail.com': 0.27; 'errors.': 0.27; 'var': 0.27; 'function': 0.28; 'declared': 0.29; 'far,': 0.29; 'implicitly': 0.29; 'searches': 0.29; 'terminating': 0.29; 'code': 0.30; 'up.': 0.32; 'non': 0.32; 'statement': 0.32; 'point': 0.33; 'problem': 0.33; 'that,': 0.34; 'gets': 0.35; 'received:google.com': 0.35; 'could': 0.35; 'something': 0.35; 'sometimes': 0.35; 'but': 0.36; 'there': 0.36; 'received:209.85': 0.36; 'pm,': 0.36; 'subject:: ': 0.37; 'really': 0.37; 'things': 0.38; 'doing': 0.38; 'received:209': 0.38; 'names': 0.38; 'someone': 0.38; 'some': 0.40; 'future': 0.60; 'forget': 0.60; 'share': 0.61; 'more': 0.63; 'within': 0.64; 'introduce': 0.79; 'chrisa': 0.84; 'everything,': 0.84; 'local,': 0.84; 'to:none': 0.91; 'technically': 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=mG/1foyRFweNvDwtWTlwfFL94MN8/syPTvY/OTvydqM=; b=Pbraxe61VA7/0wtb/LU/bkQBa7981QuMAe5f5xfIT6cr6Wb5ug4mIJtmiX0IQ33rbe Z5WrKed9nJNcOypcqV3gqmGRorOUE/Tw+kDJMNjtbr2sVarcERNs5Gmw6IhcPXzcpeQP XVRO4Wx1v2SRLr4vJOxPMuRql0XYkCJ6dzZtU3CktkxOtQKhnmjCxteiFZt2P4TuQloy vojty+RSpjeslZsWReQRlNTQMT7U30MnzToDgY1lwvhoTGG/t1ypbg5ZG8f/PH9qK5kp +liAiGBcHWT9h3rxv6i6bXVh1kFE61v9mW4LZiuopkkztrqh7oSeCh0TqCKfxGN4dSIN nQiw== |
| 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=mG/1foyRFweNvDwtWTlwfFL94MN8/syPTvY/OTvydqM=; b=MoK12zB++VXMrYcqnZZ6W/3O4t8qelqWYlMFynZAAFb3i2AbSKMzfgCrTVizVhtWKl 07Z4x937GLO8Qk0/N4/22YUedwLXRuvYgo5sVN1y5etw/qCUoqiEh7KfAVgyFizGxlpf jED+PeKBAajgOXwmYUyR36aDQSuXD2tuVl1gWTREXSBGXAx602CJR+O5LzNtAbte4sV5 +11Cfki9Hg0370MxnJbZKIHOmNw9X+XVeDtVUtCihk1v6Dt3cPOuJtnGGvY4nDUvqrut 9xK4AUA3Z1sS+fvjUY4S27uXXc2JgNFliOPOKVOzW8jTJaeqyYJXsT09o7iY2hMkO2FY tr5w== |
| X-Gm-Message-State | ALoCoQlJj++CoRG0dmWAz8ke9ZqoUNwYwfK0T33pY4jhZ5qksgtgYdRB9GQdOUgUYyHO0v/xoiBI4ipJyMhFfAxbKLwXwbg9Sg== |
| X-Received | by 10.107.40.76 with SMTP id o73mr16126462ioo.157.1453030369876; Sun, 17 Jan 2016 03:32:49 -0800 (PST) |
| In-Reply-To | <n7ft2d$f7b$1@dont-email.me> |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.20+ |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe> |
| List-Archive | <http://mail.python.org/pipermail/python-list/> |
| List-Post | <mailto:python-list@python.org> |
| List-Help | <mailto:python-list-request@python.org?subject=help> |
| List-Subscribe | <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Xref | csiph.com comp.lang.python:101848 |
Show key headers only | View raw
On Sun, Jan 17, 2016 at 10:17 PM, BartC <bc@freeuk.com> wrote: > On 17/01/2016 08:25, Chris Angelico wrote: >> >> On Sun, Jan 17, 2016 at 6:37 PM, Ian Kelly <ian.g.kelly@gmail.com> wrote: >>> >>> Technically it defaults to non local. The var statement allocates a >>> variable within the current scope. Otherwise it searches up the chain of >>> parent scopes for a matching variable... >> >> >> This far, it's exactly the same as C. >> >>> ... terminating at the global scope. >> >> >> This is the bit that gets ridiculous. Undeclared variables in C are >> compile-time errors. Undeclared variables in JS are implicit globals. >> This is stupid. > > > My own language is something in-between. If a name is not declared locally, > it will look at more global scopes. If nothing is found, it will > auto-declare a local. > > So the JS bug wouldn't occur. However, there is the problem that, given a > perfectly working function with implicitly locals, at some point in the > future someone could introduce a global that will clash with the name of a > local, and screw things up. > > Because of that, the Python scheme is better on the whole. The only issue is > that sometimes you think you're assigning to a global, but it's really a > local if you forget the 'global' declaration within the function. The Python scheme makes a lot of logical sense. The C scheme (declare everything, otherwise it's an error) makes a lot of logical sense. I've never seen a hybrid scheme that makes as much sense as either of the above. In both Python's and C's ways of doing things, you can look at a single function and know which names are local and which are external. Have fun trying to share code snippets without knowing full context... ChrisA
Back to comp.lang.python | Previous | Next — Previous in thread | Find similar | Unroll thread
Keen eyes jonas.thornvall@gmail.com - 2016-01-16 14:23 -0800
Re: Keen eyes Chris Angelico <rosuav@gmail.com> - 2016-01-17 09:30 +1100
Re: Keen eyes jonas.thornvall@gmail.com - 2016-01-16 14:55 -0800
Re: Keen eyes jonas.thornvall@gmail.com - 2016-01-16 15:25 -0800
Re: Keen eyes Steven D'Aprano <steve@pearwood.info> - 2016-01-17 18:10 +1100
Re: Keen eyes Ian Kelly <ian.g.kelly@gmail.com> - 2016-01-17 00:37 -0700
Re: Keen eyes Paul Rubin <no.email@nospam.invalid> - 2016-01-16 23:52 -0800
Re: Keen eyes Chris Angelico <rosuav@gmail.com> - 2016-01-17 19:25 +1100
Re: Keen eyes BartC <bc@freeuk.com> - 2016-01-17 11:17 +0000
Re: Keen eyes Chris Angelico <rosuav@gmail.com> - 2016-01-17 22:32 +1100
csiph-web