Re: [Tutor] Fixing Globals

2013-03-17 Thread kendy
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

Re: [Tutor] Fixing Globals

2013-03-16 Thread Alan Gauld
On 16/03/13 19:04, ke...@kendy.org 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 l

Re: [Tutor] Fixing Globals

2013-03-16 Thread kendy
Wow! Quick response. I'll study the responses. THANK YOU! Ken ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Fixing Globals

2013-03-16 Thread Mitya Sirenef
On 03/16/2013 03:04 PM, ke...@kendy.org wrote: START = '<' > END = '>' > > def getargs(): > getops() > if > in_filename_1 = > in_filename_2 = > out_filename_1 = > out_filename_2 = > flag1 = > verbose = > > def this(): > open_for_read() > stuff() > > def open_for_read(filename): > in_filehandle =

Re: [Tutor] Fixing Globals

2013-03-16 Thread Dave Angel
On 03/16/2013 03:04 PM, ke...@kendy.org wrote: Dear Tutor Global constants and variables are bad. First, let me define my own "rule." Global constants should be all uppercase, and global variables should be avoided. Trivial and buggy scripts may ignore both rules. A trivial script is typic

Re: [Tutor] Fixing Globals

2013-03-16 Thread Kwpolska
On Sat, Mar 16, 2013 at 8:04 PM, wrote: > Dear Tutor > > Global constants and variables are bad. But what's better? I've heard some > suggestions, but haven't seen much actual code showing how to improve > globals. I > don't like: > > * Passing a lot of individual arguments. > * Creating a struc

[Tutor] Fixing Globals

2013-03-16 Thread kendy
Dear Tutor Global constants and variables are bad. But what's better? I've heard some suggestions, but haven't seen much actual code showing how to improve globals. I don't like: * Passing a lot of individual arguments. * Creating a structure with unrelated elements. * Passing a structure, as an