Path: csiph.com!eternal-september.org!feeder.eternal-september.org!border1.nntp.ams1.giganews.com!nntp.giganews.com!newsfeed.xs4all.nl!newsfeed7.news.xs4all.nl!news.tele.dk!news.tele.dk!small.news.tele.dk!newsgate.cistron.nl!newsgate.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.003 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'static': 0.03; 'anyway.': 0.04; 'subject:Python': 0.05; 'compiler': 0.05; 'globals': 0.09; 'statements': 0.09; 'python': 0.10; 'wed,': 0.15; 'instead.': 0.15; 'java,': 0.15; '"global"': 0.16; '4:25': 0.16; 'attributes.': 0.16; 'closures,': 0.16; 'declaration': 0.16; 'devil': 0.16; 'globals.': 0.16; 'java.': 0.16; 'lambda': 0.16; 'opposite': 0.16; 'said.': 0.16; 'wrote:': 0.16; '2015': 0.20; 'meant': 0.22; 'function,': 0.22; 'sep': 0.22; 'seems': 0.23; 'written': 0.24; 'header:In-Reply-To:1': 0.24; 'module': 0.25; 'checking': 0.27; 'message-id:@mail.gmail.com': 0.27; 'said,': 0.27; 'translated': 0.27; 'classes': 0.30; 'code': 0.30; 'statement': 0.32; 'class': 0.33; 'problem': 0.33; 'traditional': 0.33; 'members.': 0.34; 'received:google.com': 0.35; 'done': 0.35; 'c++': 0.35; 'needed': 0.36; 'there': 0.36; 'assigned': 0.36; 'keyword': 0.36; 'to:addr:python-list': 0.36; 'pm,': 0.36; 'subject:: ': 0.37; 'to:addr:python.org': 0.40; 'some': 0.40; 'ever': 0.60; 'discuss': 0.61; 'more': 0.63; 'within': 0.64; 'talking': 0.67; 'therefore': 0.67; 'obvious': 0.76; 'desaster': 0.84; 'distinguish': 0.84; 'locals': 0.84; 'to:name:python': 0.84; 'approach.': 0.91; 'mean.': 0.91 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=rrJocec5Nf9WlnLQfevAMR1+L8MHfMGA3OIW8Ou6mA0=; b=Wz3EzASh2KmoqHEQ2deYgwH4NzQ4giGEF/BHl5yNxolFmReTScnB5YPJoEJGpHPJA1 Z/pDb3QCMt45YOIWj1ewMZMIPM36glaYecbE5hI3JOSIF34dIlXWt9rUqpJ+fsPKfP/U qU9hs7miArFiQ3IPO5gNfKu0vs5DvofPdjmGul/zYec2xcqTklXywOF1Fr1tOIXBp0q8 Qk9JvWkraq45mF4G7gO9vcv45UEt8AqhGEqlZWSd9Vyma7Fo0X4/kPLj5/7tM72+JKbS kaAlhpkFIJvhwhs8Sg8M2MiAE1A/eiSNUqvFiyqtxHyC4cgYlA/Jky6Pi1JYChRdDmpC sd3Q== X-Received: by 10.129.45.194 with SMTP id t185mr12452494ywt.111.1441234676403; Wed, 02 Sep 2015 15:57:56 -0700 (PDT) MIME-Version: 1.0 In-Reply-To: <253e3584-1d4d-4e6f-b42f-2cdbfa4ad785@googlegroups.com> References: <253e3584-1d4d-4e6f-b42f-2cdbfa4ad785@googlegroups.com> From: Ian Kelly Date: Wed, 2 Sep 2015 16:57:16 -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: 30 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1441234678 news.xs4all.nl 23779 [2001:888:2000:d::a6]:46641 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:95907 On Wed, Sep 2, 2015 at 4:25 PM, wrote: > That said, it is not an overusing of globals cause globals are module vars only. > Or have you never written singletons or other classes in e.g Java, C++ with > lots of static and class members and methods using this members. I do use lots of static members in Java. 99.99% of them are constants, which if translated to Python globals would not require a global declaration anyway. Class members are not like Python globals. Class members are like Python class attributes. > With globals in Python are not meant traditional globals (app spanning vars) as already said. > Globals in Python are like class-members and statics in OO-languages. Globals are module scope! > And therefore it is not the devil or evil problem or code desaster problem > or LUA's opposite approach. > > (local/nonlocal statements I think are needed cause of lambda functionality and > is not what I try to discuss here) The local statement I was talking about has nothing to do with closures, which I think is what you mean. Within a given function, the compiler needs to have some way of knowing whether a given name is local or global. Currently that's done by the "global" keyword and by checking whether the name is ever assigned within the function. If the "global" keyword is no longer required, then there would have to be some other way for the compiler to distinguish locals from globals. The obvious solution would be to use a "local" keyword instead. That seems to me like it would be a lot more annoying.