Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!rt.uk.eu.org!newsfeed.xs4all.nl!newsfeed1.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.031 X-Spam-Evidence: '*H*': 0.94; '*S*': 0.00; 'assignment': 0.07; 'cc:addr:python-list': 0.11; 'def': 0.12; 'dict': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'globals.': 0.16; 'ironpython': 0.16; 'scope,': 0.16; 'spam"': 0.16; 'wrote:': 0.18; 'variable': 0.18; 'example': 0.22; 'cc:addr:python.org': 0.22; 'cc:2**0': 0.24; 'shown': 0.26; 'header:In-Reply-To:1': 0.27; 'message-id:@mail.gmail.com': 0.30; '>>>>': 0.31; "d'aprano": 0.31; 'ordinary': 0.31; 'steven': 0.31; 'created': 0.35; 'something': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'method': 0.36; 'pm,': 0.38; 'that,': 0.38; 'does': 0.39; 'remove': 0.60; 'simply': 0.61; "you're": 0.61; "you've": 0.63; 'skip:n 10': 0.64; 'here': 0.66; 'detail.': 0.68; 'to:none': 0.92 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=l5TaAAEDz1Ag3YTDr0YeuzFDtcAH2IXZEqcmBqAC96s=; b=h5oA9Jr4vFHY5QSxqL3mRvI+Dersj0pgs6JAND9xB2m/fEeifmY31BleZCTYaohpSW h2d4GhhcX2knSSjiZz5pcP5LD5M0F71xPM0jLdWA0ML2qeNBWJP8Rhbuab8J9OPzEsZr +xV9H6S+7LDvPLvpSmaGVWz7jNMZwB+tdOfjTHyrEN4iAWWbaavO63yct7DXYbAQCQTp Rtd8elZbaA5+DhEM9QVtl3q2G6LqLDl58wnMJ0VpdARoxLB/R5xJ5Q+n2kAjiuTfWAmc ys2wC1gJ3R82ZbIQ3e1I1p+gZnKsKVe+h2mcU43zEXOPAMI7zgsOW1PM/rK1so+Nc1zQ JRFA== MIME-Version: 1.0 X-Received: by 10.221.58.144 with SMTP id wk16mr16208257vcb.23.1399779004086; Sat, 10 May 2014 20:30:04 -0700 (PDT) In-Reply-To: <536eebc1$0$29980$c3e8da3$5496439d@news.astraweb.com> References: <235C4BFA-9770-481A-9FCF-21C3F036769C@gmail.com> <5368681D.8070602@islandtraining.com> <87ppjpwafk.fsf@elektro.pacujo.net> <536ad8f2$0$29965$c3e8da3$5496439d@news.astraweb.com> <87zjiqbmy5.fsf@elektro.pacujo.net> <536d7a7d$0$29980$c3e8da3$5496439d@news.astraweb.com> <9cc0ebf9-dbed-4d3d-91fc-2abb9b0103d0@googlegroups.com> <536dc3f7$0$29980$c3e8da3$5496439d@news.astraweb.com> <536decca$0$29980$c3e8da3$5496439d@news.astraweb.com> <536E799D.6080602@stoneleaf.us> <536eebc1$0$29980$c3e8da3$5496439d@news.astraweb.com> Date: Sun, 11 May 2014 13:30:03 +1000 Subject: Re: Values and objects 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.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: 26 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1399779013 news.xs4all.nl 2843 [2001:888:2000:d::a6]:53917 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:71285 On Sun, May 11, 2014 at 1:17 PM, Steven D'Aprano wrote: > But that is an implementation detail. IronPython and Jython use an > ordinary dict for local variable namespaces, just like globals. Consider > this example from Jython: > >>>> spam = 9999 >>>> def modify(namespace): > ... namespace['spam'] = 42 > ... >>>> def demo(): > ... modify(locals()) > ... spam = spam > ... return spam > ... >>>> demo() > 42 All you're proving here is that, in some Pythons, locals() is writeable. What happens if you remove the "spam = spam" line? Would demo() not then return spam from the global scope, because the variable does not exist at local scope? Every example you've shown is simply giving a value to something that you've created by the normal method of having an assignment inside the function. ChrisA