Path: csiph.com!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!newsfeed.xs4all.nl!newsfeed4.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail 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; 'cpython': 0.05; 'interpreter': 0.05; 'subject:Python': 0.06; 'assignment': 0.07; 'interpreter.': 0.07; 'table.': 0.07; 'variables': 0.07; 'function,': 0.09; 'impose': 0.09; 'runtime': 0.09; 'subject:language': 0.09; 'cc:addr:python-list': 0.11; 'changes': 0.15; "'''": 0.16; 'bind': 0.16; 'cc:name:python list': 0.16; 'dict': 0.16; 'exception;': 0.16; 'reedy': 0.16; 'returned,': 0.16; 'semantically': 0.16; 'subject:programming': 0.16; 'wording': 0.16; 'index': 0.16; 'wrote:': 0.18; 'code.': 0.18; 'unlike': 0.19; 'meant': 0.20; 'cc:addr:python.org': 0.22; 'question': 0.24; 'cc:2**0': 0.24; 'subject:/': 0.26; 'values': 0.27; 'header:In-Reply-To:1': 0.27; 'function': 0.29; 'rest': 0.29; 'am,': 0.29; 'raise': 0.29; 'returned': 0.30; 'message- id:@mail.gmail.com': 0.30; 'code': 0.31; 'that.': 0.31; 'usually': 0.31; 'agreed.': 0.31; "d'aprano": 0.31; 'steven': 0.31; 'class': 0.32; 'this.': 0.32; 'says': 0.33; 'not.': 0.33; 'december': 0.35; 'case,': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'really': 0.36; 'representing': 0.36; "didn't": 0.36; 'should': 0.36; 'too': 0.37; 'e.g.': 0.38; 'called': 0.40; 'even': 0.60; 'free': 0.61; 'affect': 0.61; 'full': 0.61; 'name': 0.63; 'temporary': 0.65; 'note:': 0.66; 'between': 0.67; 'oscar': 0.84; 'absolutely': 0.87; '2013': 0.98 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 :cc:content-type; bh=DbqXssjhM6ZOGQxcElDMk7wj0Rg/dl5wSM2opCYSzW8=; b=Jr47Ujuhekaw2LQcXaVr8NnAK6IwcjAfhCylGJYZyQuoiQxMmqCtHOiebxEDYZI9LH nBPv0foWnFSAwCcweY4gOlZIdPgY6PC3JumEY+aOAHHutQPEGByBvsjANyLNgwBhYBiU nNAVJMgJU8Dc25aGhWULlRBB0XLQ086a6CwVRuHQKGstINLYfrQctL0gW5sXCCItwUR2 nUrrowtFY0dHj6VyqGtC0Xdjj4yHIBV5ZdoABid87/p3TNnbbtuftC0UYnx52Xt+hNhX eXrzPeH5ATap8aR/xWJS26gJjMU1OGKs+AzLM3XI5xoLrvj85hpiWsVSGqZjDp+mzxZt KbIw== X-Received: by 10.68.172.65 with SMTP id ba1mr9959913pbc.18.1387412486174; Wed, 18 Dec 2013 16:21:26 -0800 (PST) MIME-Version: 1.0 In-Reply-To: References: <20131212213602.806ef8fd2626ca6f34bc83d6@gmx.net> <20131216213225.2006b30246e3a08ee241a191@gmx.net> <20131217165144.39bf9ba1cd4e4f27a96893ca@gmx.net> <52b0fb4f$0$29973$c3e8da3$5496439d@news.astraweb.com> <52b15a69$0$29973$c3e8da3$5496439d@news.astraweb.com> From: Oscar Benjamin Date: Thu, 19 Dec 2013 00:21:06 +0000 Subject: Re: Experiences/guidance on teaching Python as a first programming language To: Terry Reedy Content-Type: text/plain; charset=ISO-8859-1 Cc: Python List X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 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: 57 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1387412489 news.xs4all.nl 2834 [2001:888:2000:d::a6]:34327 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:62348 On 18 December 2013 22:33, Terry Reedy wrote: > On 12/18/2013 3:18 AM, Steven D'Aprano wrote: > >> We don't know what locals()['spam'] = 42 will do inside a function, > > I am mystified that you would write this. Locals() will "Update and return a > dictionary representing the current local symbol table." The only thing > unspecified is the relation between the 'current local symbol table' and the > *dict* that 'represents' it. Given that a dict is returned, the rest is > unambiguous. It's not unambiguous. The full wording is: ''' locals() Update and return a dictionary representing the current local symbol table. Free variables are returned by locals() when it is called in function blocks, but not in class blocks. Note: The contents of this dictionary should not be modified; changes may not affect the values of local and free variables used by the interpreter. ''' The part that says "changes may ..." is deliberately ambiguous; the author didn't want to impose too strong a constraint on any particular implementation. >> unlike the C case, we can reason about it: >> >> - it may bind 42 to the name "spam"; > > "somedict['spam'] = 42" will do exactly that. That's not what is usually meant by "name-binding". >> - it may raise a runtime exception; > > Absolutely not. Agreed. >> - it may even be a no-op; > > Absolutely not. Incorrect. The code in question is: locals()['spam'] = 42 and it is semantically a no-op. The index assignment on a temporary dict may actually be performed by e.g. the CPython interpreter but it is really just dead code. Oscar