Path: csiph.com!news.mixmin.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed8.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.009 X-Spam-Evidence: '*H*': 0.98; '*S*': 0.00; 'anyway.': 0.04; 'subject:Python': 0.05; 'works.': 0.07; 'dict': 0.09; 'sane': 0.09; 'work"': 0.09; 'do,': 0.15; 'ah,': 0.16; 'write,': 0.16; 'wrote:': 0.16; 'documented': 0.18; '>>>': 0.20; 'library': 0.20; '2015': 0.20; 'work,': 0.21; 'logical': 0.22; 'sep': 0.22; 'am,': 0.23; 'seems': 0.23; 'sat,': 0.23; 'header:In-Reply-To:1': 0.24; 'sort': 0.25; "doesn't": 0.26; 'sense': 0.26; 'chris': 0.26; 'fri,': 0.27; 'updating': 0.27; 'message-id:@mail.gmail.com': 0.27; 'behaviour': 0.29; 'documenting': 0.29; 'work.': 0.30; 'certainly': 0.30; 'probably': 0.31; 'especially': 0.32; 'returned': 0.32; 'source': 0.33; 'url:python': 0.33; 'gives': 0.35; 'received:google.com': 0.35; 'execution': 0.35; 'but': 0.36; 'skip:i 20': 0.36; 'url:org': 0.36; 'created': 0.36; 'url:library': 0.36; 'to:addr:python-list': 0.36; 'subject:: ': 0.37; '12,': 0.37; "won't": 0.38; 'to:addr:python.org': 0.40; 'url:3': 0.60; '(that': 0.63; 'worth': 0.67; 'url:4': 0.70; '"it': 0.84; 'locals': 0.84; 'to:name:python': 0.84; 'url:functions': 0.84; 'using.': 0.84 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 :content-type; bh=FaFSj2Tz9VjT7D+2YegZVCZmfZDEpnEei8C7giYZqqk=; b=NrwcsacjRKJ6tynogP40P+vljgftlfuNRKcgIWg6leN64xBYyJIqyu75wm9qeON0Vr qU8tkrhrNdZCy+Yt0ppdxpTYE31n0elMdS91i59B0zsn0j8PyEYdCnL1lYXY89aTTh61 xaNEZzFV7mBF3mzytANJOMm45dwfT2XAqlhh7ZitJ8mMOtVsuOWfQKxF+BaUA4HS5JiH oAkALwX0m6iHY0vu34gCQ0fWeg/2h2p+8IhirWEzj1JB+5oQMNAw7owpR6UWC2jeHMIU uy2lJC8Sgb4D4dWE6oQH3m97crQ7GFfioQ/njHy269yNxnQbvmZS0Hx4jw3viIAvKxVj MW+A== X-Received: by 10.129.145.214 with SMTP id i205mr8098314ywg.64.1441988916813; Fri, 11 Sep 2015 09:28:36 -0700 (PDT) MIME-Version: 1.0 In-Reply-To: References: <55f293da$0$1640$c3e8da3$5496439d@news.astraweb.com> <1441987052.3506145.381042489.570191F2@webmail.messagingengine.com> From: Ian Kelly Date: Fri, 11 Sep 2015 10:27:57 -0600 Subject: Re: Python handles globals badly. To: Python 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: 26 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1441988920 news.xs4all.nl 23818 [2001:888:2000:d::a6]:44084 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:96356 On Fri, Sep 11, 2015 at 10:04 AM, Chris Angelico wrote: > On Sat, Sep 12, 2015 at 1:57 AM, wrote: >> On Fri, Sep 11, 2015, at 11:55, Chris Angelico wrote: >>> On Sat, Sep 12, 2015 at 1:49 AM, Ian Kelly wrote: >>> > Ah, that makes sense. It's writing into the dict that is created and >>> > returned by locals(), but not actually updating the frame locals which >>> > are the source of truth. >>> >>> Yeah... but it only makes sense to people who understand the >>> implementation. It's certainly not a logical and sane behaviour that >>> would be worth documenting and using. >> >> What else would you document? Reading from them is a reasonable thing to >> do, and works. Writing to them is a reasonable thing to want to do, but >> won't work, so you need to document that it doesn't work. > > Documenting that "it doesn't work" seems fine. Documenting the > specific behaviour (that it gives you a sort of "shadow" locals, into > which you can write, but which won't persist past the execution of > that block of code) seems pointless. Especially since this behaviour > is implementation-dependent anyway. It's documented in the standard library docs: https://docs.python.org/3.4/library/functions.html#exec I think that's probably sufficient.