Path: csiph.com!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!newsfeed.xs4all.nl!newsfeed3.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.012 X-Spam-Evidence: '*H*': 0.98; '*S*': 0.00; 'python,': 0.02; '16,': 0.03; 'extends': 0.09; 'function,': 0.09; 'variable,': 0.09; 'accesses': 0.16; 'declarations': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'local.': 0.16; 'module).': 0.16; 'scopes': 0.16; 'sat,': 0.16; 'wrote:': 0.18; 'variable': 0.18; 'module': 0.19; '(in': 0.22; 'otherwise,': 0.22; 'simpler': 0.24; 'this:': 0.26; 'header:In-Reply-To:1': 0.27; "doesn't": 0.30; 'message-id:@mail.gmail.com': 0.30; 'code': 0.31; 'that.': 0.31; 'level.': 0.33; "can't": 0.35; 'beyond': 0.35; 'johnson': 0.35; 'received:google.com': 0.35; 'really': 0.36; 'var': 0.36; 'level': 0.37; 'nov': 0.38; 'to:addr:python-list': 0.38; 'pm,': 0.38; 'to:addr:python.org': 0.39; 'even': 0.60; 'worry': 0.60; 'till': 0.61; "you're": 0.61; 'surrounding': 0.68; 'containing': 0.69; 'it"': 0.84; 'subject:Global': 0.91; 'rick': 0.93; '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:date:message-id:subject:from:to :content-type; bh=WvT9roPRjkbBaLXLkCWyc0Ge13dtCDaq0IVIb1fGxWY=; b=ZuKZ45kGc0d1qLQuBaJgGjgvX9D3wCCUkHfJv/yujrW3T3FtJkYUaxFilqTVK2iB8o 9kWSwr+iT/L5mYzmTnyPZBtntnIVqxeORFNSIz1CiOSbxxsEJAvWn47jlvsQM5Wkb1wA yIP/CBRxPdSmmPigcCMGdUGH1OsBBk+VHexUyyWkusoFKpFVpSJ5FcJyalJ6sNeK6SgT kx/bYcqZ/ckrkUEp8+hSv8XdPL90KOqAuVi/QWgck++CTnwnOfV31tMCn25W0kHgxZeL xbNkzZd5tzCA0KUaj16MAaBiBGySeDW5rhdgNQpVSS0ZOFVvikq18xUGqSWfYUEROmTy Vq3g== MIME-Version: 1.0 X-Received: by 10.68.225.232 with SMTP id rn8mr9693924pbc.32.1384575259051; Fri, 15 Nov 2013 20:14:19 -0800 (PST) In-Reply-To: <21450235-0e30-41c3-8d97-d253d6d13371@googlegroups.com> References: <7b97786a-2aaf-454c-8c3a-1c19d20d4345@googlegroups.com> <2373cb88-c3e8-46ee-bf0c-82bb69c97226@googlegroups.com> <5284393c$0$29975$c3e8da3$5496439d@news.astraweb.com> <528464af$0$29971$c3e8da3$5496439d@news.astraweb.com> <5285d8f4$0$29975$c3e8da3$5496439d@news.astraweb.com> <21450235-0e30-41c3-8d97-d253d6d13371@googlegroups.com> Date: Sat, 16 Nov 2013 15:14:18 +1100 Subject: Re: PyMyth: Global variables are evil... WRONG! From: Chris Angelico To: python-list@python.org Content-Type: text/plain; charset=ISO-8859-1 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: 21 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1384575619 news.xs4all.nl 15935 [2001:888:2000:d::a6]:43634 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:59591 On Sat, Nov 16, 2013 at 3:01 PM, Rick Johnson wrote: > Because when i see code that accesses a variable like this: > > var = value > > I have no way of knowing whether the mutation is happening > to a local variable, a module level variable, or even a true > global level variable (one which extends beyond the > containing module). If it's in a function, and there's no global/nonlocal declaration, it's local. Otherwise, it's module level. It can't be process-level in Python, so you don't need to worry about that. It doesn't get much simpler than that without variable declarations (in which case it's "scan surrounding scopes till you find a declaration, that's it" - and it's arguable whether that's simpler or not). Really Rick, you're clutching at straws here. ChrisA