Global in multiple files

James Logajan JamesL at Lugoj.Com
Sun Jun 10 17:34:42 EDT 2001


Artur Skura wrote:
> (BTW I would like to thank other people for pointing out the
> possibility of having global.py module etc. Yes, it solves my
> problem for now, but maybe I should really redesign it as Roman
> suggest to eliminate the need. No, I still don't know how :))

I would advise against putting any effort into removing a single global; it
is not be worth your while. In fact there is nothing "wrong" with globals
per se (speaking from ~26 years of programming experience). Don't worry
about removing globals, concentrate instead on containment relationships. 
Some "top level" objects and relationships properly belong in the global
name space.

P.S. The main execution frame must start from some name space, normally
called the "global" namespace. So at least one (and usually more) object
references must be contained in it. You can't get around that basic
requirement no matter how much object oriented analysis you care to do.

P.P.S. I've never been able to figure out why people insist on keeping the
global name space as free of objects as possible while not applying that
obsession to other name spaces. True, beginners tend to put everything in
the global name space, but no insight on how to organize relationships is
going to be imparted by telling them not to put things in the global name
space. There is a point when that kind of 30-second "wisdom" becomes unwise.



More information about the Python-list mailing list