Re: PyMyth: Global variables are evil... WRONG!

2013-11-15 Thread Chris Angelico
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 ex

Re: PyMyth: Global variables are evil... WRONG!

2013-11-15 Thread Chris Angelico
On Sat, Nov 16, 2013 at 3:01 PM, Rick Johnson wrote: > Let's see... Tkinter's design today is a single module > containing a staggering: > > 155,626 chars > > 3,733 lines Also: I see nothing wrong with a single module having 3-4K lines in it. Hilfe, the Pike REPL/interactive interpreter,

Re: PyMyth: Global variables are evil... WRONG!

2013-11-15 Thread Rick Johnson
On Friday, November 15, 2013 2:19:01 AM UTC-6, Steven D'Aprano wrote: > But with software, coupling is *easy*. By default, code in > a single process is completely coupled. Think of a chunk > of machine code running in a single piece of memory. We > have to build in our own conventions for decoupl

Re: PyMyth: Global variables are evil... WRONG!

2013-11-15 Thread Tim Daneliuk
On 11/15/2013 09:42 AM, Chris Angelico wrote: On Sat, Nov 16, 2013 at 2:26 AM, Tim Daneliuk wrote: On 11/15/2013 02:19 AM, Steven D'Aprano wrote: Nobody sets out to*design* a tangled mess. What normally happens is that a tangled mess is the result of*lack of design*. This has been an intere

Re: PyMyth: Global variables are evil... WRONG!

2013-11-15 Thread Tim Daneliuk
On 11/15/2013 02:19 AM, Steven D'Aprano wrote: Nobody sets out to*design* a tangled mess. What normally happens is that a tangled mess is the result of*lack of design*. This has been an interesting thread - to me anyway - but this bit above caught my eye. People write programs for lots of rea

Re: PyMyth: Global variables are evil... WRONG!

2013-11-15 Thread Chris Angelico
On Sat, Nov 16, 2013 at 2:26 AM, Tim Daneliuk wrote: > On 11/15/2013 02:19 AM, Steven D'Aprano wrote: >> Nobody sets out to*design* a tangled mess. What normally happens is that >> a tangled mess is the result of*lack of design*. > > This has been an interesting thread - to me anyway - but this b

Re: PyMyth: Global variables are evil... WRONG!

2013-11-15 Thread Steven D'Aprano
On Thu, 14 Nov 2013 09:26:18 -0800, Rick Johnson wrote: > On Wednesday, November 13, 2013 11:50:40 PM UTC-6, Steven D'Aprano > wrote: [...] >> of course, but that in general *its too damn hard* for human >> programmers to write good, reliable, maintainable, correct (i.e. >> bug-free) code using pr

Re: PyMyth: Global variables are evil... WRONG!

2013-11-14 Thread Chris Angelico
On Fri, Nov 15, 2013 at 7:12 AM, Alister wrote: > Ricks non trolling posts do give him enough credibility to avoid > dismissing his ideas out of hand When he's talking about Tkinter, he knows his stuff, and is orders of magnitude more helpful than I would be (as I don't know Tkinter). When he's t

Re: PyMyth: Global variables are evil... WRONG!

2013-11-14 Thread Alister
On Thu, 14 Nov 2013 09:56:04 -0800, Ethan Furman wrote: > On 11/14/2013 09:37 AM, Joel Goldstick wrote: >> >> So, beyond that, what is the point of the thread? > > You haven't met Ranting Rick yet? He's a troll's troll, outdone only by > one other whose name I don't remember. > > His posts are,

Re: PyMyth: Global variables are evil... WRONG!

2013-11-14 Thread Mark Lawrence
On 14/11/2013 17:56, Ethan Furman wrote: On 11/14/2013 09:37 AM, Joel Goldstick wrote: So, beyond that, what is the point of the thread? You haven't met Ranting Rick yet? He's a troll's troll, outdone only by one other whose name I don't remember. His posts are, amazingly enough, rants. Us

Re: PyMyth: Global variables are evil... WRONG!

2013-11-14 Thread Joel Goldstick
On Thu, Nov 14, 2013 at 12:56 PM, Ethan Furman wrote: > On 11/14/2013 09:37 AM, Joel Goldstick wrote: >> >> >> So, beyond that, what is the point of the thread? > > > You haven't met Ranting Rick yet? He's a troll's troll, outdone only by one > other whose name I don't remember. > > His posts are

Re: PyMyth: Global variables are evil... WRONG!

2013-11-14 Thread Ethan Furman
On 11/14/2013 09:37 AM, Joel Goldstick wrote: So, beyond that, what is the point of the thread? You haven't met Ranting Rick yet? He's a troll's troll, outdone only by one other whose name I don't remember. His posts are, amazingly enough, rants. Usually about his (mis)perceptions of the

Re: PyMyth: Global variables are evil... WRONG!

2013-11-14 Thread Joel Goldstick
On Thu, Nov 14, 2013 at 12:26 PM, Rick Johnson wrote: > On Wednesday, November 13, 2013 11:50:40 PM UTC-6, Steven D'Aprano wrote: >> On Wed, 13 Nov 2013 19:45:42 -0800, Rick Johnson wrote: >> > On Wednesday, November 13, 2013 8:45:16 PM UTC-6, Steven D'Aprano wrote: >> >> A fully-auto machine gun

Re: PyMyth: Global variables are evil... WRONG!

2013-11-14 Thread Rick Johnson
On Wednesday, November 13, 2013 11:50:40 PM UTC-6, Steven D'Aprano wrote: > On Wed, 13 Nov 2013 19:45:42 -0800, Rick Johnson wrote: > > On Wednesday, November 13, 2013 8:45:16 PM UTC-6, Steven D'Aprano wrote: > >> A fully-auto machine gun with a hair-trigger and no > >> safety is no different fro

Re: PyMyth: Global variables are evil... WRONG!

2013-11-14 Thread unknown
On Thu, 14 Nov 2013 14:29:41 +1100, Chris Angelico wrote: > On Thu, Nov 14, 2013 at 2:22 PM, Rick Johnson > wrote: >> Yeah, a "global" keyword that extends access ONLY as far as module >> level scope -- hardly a *true* global. > > I have yet to see any language that gives true globals. At very b

Re: PyMyth: Global variables are evil... WRONG!

2013-11-13 Thread Steven D'Aprano
On Wed, 13 Nov 2013 23:33:22 -0500, Roy Smith wrote: > In article , > Chris Angelico wrote: > >> I have yet to see any language that gives true globals. At very best, >> they're just process-wide! Honestly. How am I supposed to write code >> that accesses variables running on my New York server

Re: PyMyth: Global variables are evil... WRONG!

2013-11-13 Thread Steven D'Aprano
On Wed, 13 Nov 2013 19:45:42 -0800, Rick Johnson wrote: > On Wednesday, November 13, 2013 8:45:16 PM UTC-6, Steven D'Aprano wrote: >> A fully-auto machine gun with a hair-trigger and no >> safety is no different from a single-barrel shotgun with a safety and >> a trigger lock! You can blow your

Re: PyMyth: Global variables are evil... WRONG!

2013-11-13 Thread Chris Angelico
On Thu, Nov 14, 2013 at 3:33 PM, Roy Smith wrote: > In article , > Chris Angelico wrote: > >> I have yet to see any language that gives true globals. At very best, >> they're just process-wide! Honestly. How am I supposed to write code >> that accesses variables running on my New York server? >

Re: PyMyth: Global variables are evil... WRONG!

2013-11-13 Thread Rick Johnson
On Wednesday, November 13, 2013 10:33:22 PM UTC-6, Roy Smith wrote: > Wait, aren't you the guy who's into MUDs? Yes he is. But that's his second favorite hobby. His first is filling the "Devils Advocate" slot when Steven is too busy -- doing WHATEVER Steven does when he's not here. God only

Re: PyMyth: Global variables are evil... WRONG!

2013-11-13 Thread Roy Smith
In article , Chris Angelico wrote: > I have yet to see any language that gives true globals. At very best, > they're just process-wide! Honestly. How am I supposed to write code > that accesses variables running on my New York server? Any one of a slew of remote procedure call protocols. These

Re: PyMyth: Global variables are evil... WRONG!

2013-11-13 Thread Rick Johnson
And what's this? *picks up hat* Where did this hat come from??? Spectator interrupts: Maybe Steven threw his hat in? No, no. Can't be. Steven would not wear something this old. I mean, it looks like something a farmer would put on a scarecrow or something??? *scratched head* OH

Re: PyMyth: Global variables are evil... WRONG!

2013-11-13 Thread Rick Johnson
On Wednesday, November 13, 2013 8:45:16 PM UTC-6, Steven D'Aprano wrote: > A fully-auto machine gun with a hair-trigger and no > safety is no different from a single-barrel shotgun with > a safety and a trigger lock! You can blow your foot off > with both! Yes. But in the case of the shotgun

Re: PyMyth: Global variables are evil... WRONG!

2013-11-13 Thread Chris Angelico
On Thu, Nov 14, 2013 at 2:22 PM, Rick Johnson wrote: > Yeah, a "global" keyword that extends access ONLY as far as > module level scope -- hardly a *true* global. I have yet to see any language that gives true globals. At very best, they're just process-wide! Honestly. How am I supposed to write

Re: PyMyth: Global variables are evil... WRONG!

2013-11-13 Thread Rick Johnson
On Wednesday, November 13, 2013 7:09:42 PM UTC-6, Steven D'Aprano wrote: > On Wed, 13 Nov 2013 23:42:24 +, Rhodri James wrote: > > On Tue, 12 Nov 2013 02:06:09 -, Rick Johnson wrote: > >> Python has globals, but we just can't admit it! > > A different subject entirely, but no more accuratel

Re: PyMyth: Global variables are evil... WRONG!

2013-11-13 Thread Steven D'Aprano
On Wed, 13 Nov 2013 18:10:59 -0800, Rick Johnson wrote: > On Wednesday, November 13, 2013 5:42:24 PM UTC-6, Rhodri James wrote: >> On Tue, 12 Nov 2013 02:06:09 -, Rick Johnson wrote: >> > PyMyth: Global variables are evil... WRONG! >> That's not a PyMyth. It&#

Re: PyMyth: Global variables are evil... WRONG!

2013-11-13 Thread Rick Johnson
On Wednesday, November 13, 2013 6:17:22 PM UTC-6, Tim Daneliuk wrote: > > But python modules can't be interfaces because interfaces > > should protect internal data, prevent external forces from > > meddling with internal state (EXCEPT via the rules of a > > predefined "contract"), hide dirty detai

Re: PyMyth: Global variables are evil... WRONG!

2013-11-13 Thread Rick Johnson
On Wednesday, November 13, 2013 4:00:15 PM UTC-6, Andrew Cooper wrote: > And what do you do when the wizards bend space-time to > make PI exactly 3, for the ease of other calculations when > building a sorting machine? Are you telling me that these wizards can't be bothered to write the integer "3

Re: PyMyth: Global variables are evil... WRONG!

2013-11-13 Thread Rick Johnson
On Wednesday, November 13, 2013 5:42:24 PM UTC-6, Rhodri James wrote: > On Tue, 12 Nov 2013 02:06:09 -, Rick Johnson wrote: > > PyMyth: Global variables are evil... WRONG! > That's not a PyMyth. It's a CompSciMyth, or to be more > accurate a good general Softw

Re: PyMyth: Global variables are evil... WRONG!

2013-11-13 Thread Steven D'Aprano
On Wed, 13 Nov 2013 23:42:24 +, Rhodri James wrote: > On Tue, 12 Nov 2013 02:06:09 -, Rick Johnson > wrote: > >> PyMyth: Global variables are evil... WRONG! > > That's not a PyMyth. It's a CompSciMyth, or to be more accurate a good > general Softwar

Re: PyMyth: Global variables are evil... WRONG!

2013-11-13 Thread Tim Daneliuk
On 11/11/2013 10:46 PM, Rick Johnson wrote: On Monday, November 11, 2013 8:47:09 PM UTC-6, Tim Daneliuk wrote: I think this is certainly the use case most people would suggest. But I think you may have missed the real reason most modern designers object to inter-module globals: The presence of

Re: PyMyth: Global variables are evil... WRONG!

2013-11-13 Thread Mark Lawrence
On 13/11/2013 23:42, Rhodri James wrote: On Tue, 12 Nov 2013 02:06:09 -, Rick Johnson wrote: PyMyth: Global variables are evil... WRONG! That's not a PyMyth. It's a CompSciMyth, or to be more accurate a good general Software Engineering guideline regardless of language.

Re: PyMyth: Global variables are evil... WRONG!

2013-11-13 Thread Rhodri James
On Tue, 12 Nov 2013 02:06:09 -, Rick Johnson wrote: PyMyth: Global variables are evil... WRONG! That's not a PyMyth. It's a CompSciMyth, or to be more accurate a good general Software Engineering guideline regardless of language. Like all guidelines it can be broken,

Re: PyMyth: Global variables are evil... WRONG!

2013-11-13 Thread Andrew Cooper
On 13/11/2013 02:45, Rick Johnson wrote: > > "math.pi" should be "math.PI". and PI should be a CONSTANT. > And not just a pseudo constant, but a REAL constant that > cannot be changed. > And what do you do when the wizards bend space-time to make PI exactly 3, for the ease of other calculation

Re: PyMyth: Global variables are evil... WRONG!

2013-11-12 Thread Tim Chase
On 2013-11-12 18:45, Rick Johnson wrote: > "math.pi" should be "math.PI". It's a real shame that this fails: >>> math.PI = math.pi oh...wait... > and PI should be a CONSTANT. And not just a pseudo constant, but a > REAL constant that cannot be changed. How much precision do you want? Perhap

Re: PyMyth: Global variables are evil... WRONG!

2013-11-12 Thread Rick Johnson
On Tuesday, November 12, 2013 4:41:34 PM UTC-6, jongiddy wrote: > On Tuesday, November 12, 2013 5:00:37 PM UTC, Rick Johnson wrote: > >1. Accept that globals are useful, and make them > > available through a "real" global syntax, not > > some attribute of a module that "appears" to

Re: PyMyth: Global variables are evil... WRONG!

2013-11-12 Thread Terry Reedy
On 11/11/2013 11:46 PM, Rick Johnson wrote: No, Python modules can be poked, prodded, and violated by any pervert who can spell the word "import". Or by clever programmers. Attribute values can be reassigned and state can be externally manipulated Perhaps for good reasons. resulting in a

Re: PyMyth: Global variables are evil... WRONG!

2013-11-12 Thread jongiddy
On Tuesday, November 12, 2013 5:00:37 PM UTC, Rick Johnson wrote: > > >1. Accept that globals are useful, and make them > > available through a "real" global syntax, not > > some attribute of a module that "appears" to be > > local, but in reality is global. Then prevent

Re: PyMyth: Global variables are evil... WRONG!

2013-11-12 Thread Rick Johnson
On Tuesday, November 12, 2013 11:00:37 AM UTC-6, Rick Johnson wrote: [snip] > We have all been brainwashed by authorities. First they > give us rules, then they give us the power to break > those rules. The devil himself said it best: http://www.youtube.com/watch?v=RGR4SFOimlk Hmm. How do we

Re: PyMyth: Global variables are evil... WRONG!

2013-11-12 Thread Tim Chase
On 2013-11-12 09:00, Rick Johnson wrote: > Because the constant PI should never change. Sure we can > argue about granularity of PI, but that argument has no > weight on the fact that PI should be a constant. > > By placing PI in the module "math", we are creating a pseudo > interface. We (the cre

Re: PyMyth: Global variables are evil... WRONG!

2013-11-12 Thread Rick Johnson
On Tuesday, November 12, 2013 9:33:50 AM UTC-6, jongiddy wrote: > I'm not sure where you get the feeling you're accessing an > interface. Because the constant PI should never change. Sure we can argue about granularity of PI, but that argument has no weight on the fact that PI should be a constant

Re: PyMyth: Global variables are evil... WRONG!

2013-11-12 Thread jongiddy
On Tuesday, November 12, 2013 3:05:25 PM UTC, Rick Johnson wrote: > > > > When i type "math.pi", i "feel" as though i'm accessing an > > interface, BUT I'M NOT! I'm not sure where you get the feeling you're accessing an interface. If I typed this, I would feel like I was trying to change a f

Re: PyMyth: Global variables are evil... WRONG!

2013-11-12 Thread Chris Angelico
On Wed, Nov 13, 2013 at 1:32 AM, Alister wrote: > As an analogy music has may general rules that musicians are wise to > follow. > Some pieces of music that break these rules are great because they have > broken the rules but most are not. those that are great are great because > the musician in q

Re: PyMyth: Global variables are evil... WRONG!

2013-11-12 Thread Rick Johnson
On Tuesday, November 12, 2013 8:12:10 AM UTC-6, jongiddy wrote: > Can you please give an example where having a module > provide a global variable would work better than any of: > [snip] Well my point is that the attributes of any Python module are "emulating" globals already. The fact that we ha

Re: PyMyth: Global variables are evil... WRONG!

2013-11-12 Thread Alister
On Mon, 11 Nov 2013 18:06:09 -0800, Rick Johnson wrote: > > In this thread, i want to get to the bottom of this whole > "global-phobia" thing once and for all, and hopefully help you folks > understand that globals are not all that bad -- when DESIGNED and USED > correctly that is! it is the fin

Re: PyMyth: Global variables are evil... WRONG!

2013-11-12 Thread jongiddy
On Tuesday, November 12, 2013 2:06:09 AM UTC, Rick Johnson wrote: > > > > Justifying Global Variables: > > > > Globals are justified when they are used to communicate > >

Re: PyMyth: Global variables are evil... WRONG!

2013-11-12 Thread Tim Chase
On 2013-11-11 20:46, Rick Johnson wrote: > Yes, and i agree. But you cannot "hide" everything. There > will always be a need to share information. You may not be able to (or want to) hide everything, but sharing should at least happen over defined protocols (functions/methods). Otherwise, you wand

Re: PyMyth: Global variables are evil... WRONG!

2013-11-12 Thread Ricardo Aráoz
El 12/11/13 01:46, Rick Johnson escribió: No, Python modules can be poked, prodded, and violated by any pervert who can spell the word "import". Attribute values can be reassigned and state can be externally manipulated resulting in all types of undefined behaviors -- Nice! My code, my respo

Re: PyMyth: Global variables are evil... WRONG!

2013-11-11 Thread Chris Angelico
On Tue, Nov 12, 2013 at 3:46 PM, Rick Johnson wrote: > But python modules can't be interfaces because interfaces > should protect internal data, prevent external forces from > meddling with internal state (EXCEPT via the rules of a > predefined "contract"), hide dirty details from the caller, > an

Re: PyMyth: Global variables are evil... WRONG!

2013-11-11 Thread Rick Johnson
On Monday, November 11, 2013 8:47:09 PM UTC-6, Tim Daneliuk wrote: > I think this is certainly the use case most people would > suggest. But I think you may have missed the real reason > most modern designers object to inter-module globals: The > presence of such entities almost always means the c

Re: PyMyth: Global variables are evil... WRONG!

2013-11-11 Thread Tim Daneliuk
On 11/11/2013 08:06 PM, Rick Johnson wrote: Globals are justified when they are used to communicate information between scopes that otherwise were meant to be mutually exclusive. I think this is certainly the use case most people would suggest. But I think you may have missed the real reason

PyMyth: Global variables are evil... WRONG!

2013-11-11 Thread Rick Johnson
PyMyth: Global variables are evil... WRONG! Python's Global Hysteria: How many times have your heard or read the phrase: "Global variables are evil"? Well i