Thanks to everyone who responded. I learned from each person's response. The example code that I emailed was representative of many large programs that I've written in other languages. I've written many small Python scripts and I'm about to write a more complex Python script, much like the example -- needing help with globals. Thanks for your help!!!
Alan's response was particularly interesting. On Sat Mar 16 16:07 , Alan Gauld sent: >On 16/03/13 19:04, [email protected] wrote: > >> Global constants and variables are bad. > >Really? Do you know why? >If you understand why then the measures to avoid them >become more palatable - the lesser of 2 evils. > >Read-only globals are much less of a problem than read/write ones. >And in Python we limit the damage by restricting globals to a single >module's scope. class variables do a similar job in OOP. Why are they bad? Hmmm. Because people say so? Hmmm. It's best to restrict dependencies. It's not fun to change one thing that affects many, far-away places. I actually don't mind globals if they're done well. I think passing a long list of arguments is the worst -- it becomes a big management issue and it clutters. Better programming helps minimize globals and long argument lists, but I don't see how they can always be eliminated. Books and teachers usually don't go into much detail about globals. I think that this is an important topic and I want to learn more. I now have more confidence but don't have a total grasp. Best regards, Ken _______________________________________________ Tutor maillist - [email protected] To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
