Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #95933

Re: Python handles globals badly.

Newsgroups comp.lang.python
Date 2015-09-03 06:22 -0700
References <c3363$547e74fe$5419aafe$24179@news.ziggo.nl>
Message-ID <3bbeafa4-d756-46f8-9750-2fca29617cf4@googlegroups.com> (permalink)
Subject Re: Python handles globals badly.
From tdev@freenet.de

Show all headers | View raw


Reflecting the answers I want to add following first:


I should have better started a new thread.
But now it is here, I want just clarify something before 
I move on (later) with repsonding.


I think this has lead to some confusing.


There are now two main topics in this thread.


First topic: 
"sharing globals between modules"
Where globals is meant as vars used throughout the app.

This is the topic why Skybuck starts the thread.
And yes I agree globals can be bad design
and it is solved via outsourcing to an extra module and used via imports.

I misinterpreted this topic a little by thinking 
the focus is more about the use of the badly "global" keyword
(in my point of view) and added therefore my post here as


Second topic: 
"Forced to use "global" for write-access inside functions 
is over-regulation and should be removed."

This topic has nothing todo with sharing globals.
It is about in the scope of a single module only.

When I have written globals in this topic 
I have meant and mean vars defined in a module outside 
functions and used inside function blocks.

Sorry if this has lead to confusion, but so long 
I have read docs I would say that these vars are 
often named as globals although I meant module vars.

Reason is that module scope is the highest
scope and often referred as the global scope.
That is also why I dislike the word "global" too.


I talk about this construct:

Sample "Bad":
module A
   _x = 0

   def y():
	global x
	_x=1


and I aim for - it would be nicer to allow for simplicity
writing this without the keyword "global"
and give this small responsibility ("write protection")
back to the developer:

Sample "Good":
module A
   _x = 0

   def y():
	_x=1


why - this I have tried and try to explain in my and your posts 
      in the hope a PEP will arise which frees me and hopefully
      a lot other developers getting forced to use "global"
      (If developers need this "global" - ok, but I and 
	hopefully more want not to be forced with that 
        code-contaminator, especially having a lot more vars)


Said that, I will not respond to comments about sharing globals

Back to comp.lang.python | Previous | NextNext in thread | Find similar | Unroll thread


Thread

Re: Python handles globals badly. tdev@freenet.de - 2015-09-03 06:22 -0700
  Re: Python handles globals badly. Chris Angelico <rosuav@gmail.com> - 2015-09-04 00:03 +1000
  Re: Python handles globals badly. Michael Torrie <torriem@gmail.com> - 2015-09-03 09:50 -0600
  Re: Python handles globals badly. Ian Kelly <ian.g.kelly@gmail.com> - 2015-09-03 10:15 -0600
  Re: Python handles globals badly. Michael Torrie <torriem@gmail.com> - 2015-09-03 10:43 -0600
    Re: Python handles globals badly. Steven D'Aprano <steve@pearwood.info> - 2015-09-04 12:05 +1000
    Re: Python handles globals badly. pepekbabi5@gmail.com - 2015-09-06 15:35 -0700
  Re: Python handles globals badly. MRAB <python@mrabarnett.plus.com> - 2015-09-03 19:29 +0100
  Re: Python handles globals badly. Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2015-09-03 18:41 -0400

csiph-web