[Chicago] Using globals across files

Jason Rexilius jason at hostedlabs.com
Wed Mar 29 00:00:40 CEST 2006


globals are not across-the-board bad.. abusing them is bad (which happens often enough for people to get the idea that they are bad) but there are times when a truly global variable (like a counter) is usefull.

I am surprised that this type of construct doesn't exist in Python.. 

On Tue, 28 Mar 2006 15:18:39 -0600, Chris Cope <chris at copester.com> wrote:
> Yes this is a bad programming practice, that I avoid, and have avoided
> for a long time. But for this example, where I want a lot of files to
> all increment the same counters, it seemed like a good idea at the time.
> ;)
> 
> Whatever works, right?
> Chris
> 
> Martin Maney wrote:
>> On Mon, Mar 27, 2006 at 10:39:49AM -0600, Chris Cope wrote:
>>
>>>better approach anyway. In 4 years of programming with python, I've
>>>never used globals before, and had no idea seamlessly sharing them
>>>between files, like with an external in C, wasn't feasible. :)
>>
>>
>> While Python isn't a bondage & discipline kind of langauge, it doesn't
>> waste much effort making bad ideas easy, either.  <wink>
>>
>> This may be one of the real exceptions, but my experience has been that
>> sharing state though globals is well up on the list of things that will
>> eventually circle around and bite you in the ass.  Just sayin'.
>>
> _______________________________________________
> Chicago mailing list
> Chicago at python.org
> http://mail.python.org/mailman/listinfo/chicago



More information about the Chicago mailing list