Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #95907
| References | <c3363$547e74fe$5419aafe$24179@news.ziggo.nl> <253e3584-1d4d-4e6f-b42f-2cdbfa4ad785@googlegroups.com> |
|---|---|
| From | Ian Kelly <ian.g.kelly@gmail.com> |
| Date | 2015-09-02 16:57 -0600 |
| Subject | Re: Python handles globals badly. |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.44.1441234678.8327.python-list@python.org> (permalink) |
On Wed, Sep 2, 2015 at 4:25 PM, <tdev@freenet.de> 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.
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Re: Python handles globals badly. tdev@freenet.de - 2015-09-02 15:25 -0700 Re: Python handles globals badly. Ian Kelly <ian.g.kelly@gmail.com> - 2015-09-02 16:57 -0600 Re: Python handles globals badly. Vladimir Ignatov <kmisoft@gmail.com> - 2015-09-02 20:16 -0400 Re: Python handles globals badly. Mark Lawrence <breamoreboy@yahoo.co.uk> - 2015-09-03 02:10 +0100 Re: Python handles globals badly. Mark Lawrence <breamoreboy@yahoo.co.uk> - 2015-09-03 02:15 +0100 Re: Python handles globals badly. "Sven R. Kunze" <srkunze@mail.de> - 2015-09-04 01:06 +0200
csiph-web