Constants and Globals

Travis Beaty t.beaty at mchsi.com
Sat Dec 14 07:41:35 EST 2002


Hello everyone!

I'm an *extremely* newbie Python user, and a new member of the mailing 
list as well.  I hope that you can excuse some (more than likely) very 
basic questions as I attack the rabbit of ignorance where the language 
is concerned.  Please keep in mind though, that it's just a rabbit.   
(Docs said that references to Monty Python were encouraged ... yeah, 
that particular reference sucked, but hopefully it was enough to get me 
into good standing with the community.  LOL)

Alrighty, the questions:

1.  Is there such an animal as a "constant" in Python?  I've looked 
through the manual, documentation, and FAQ's, but I haven't been able to 
find an answer about that.  I'm sure it's there somewhere, and I've just 
overlooked it.  I noted that the term "constant" was used, but I am 
unsure whether one can actually lock the value of a variable, or whether 
such constants are simply "constant by agreement."

2.  I'm working on an application that needs to have a global variable. 
 I, of course, do my best to shy away from globals; however, since this 
is a dictionary which contains user preference settings, I can see no 
other alternative.  I've implemented this global variable by placing it 
into a module which will be imported by all other modules.  Is this the 
"standard" way that globals are created?  Again, I've read the docs and 
tutorial where variable scope is concerned, but I'm still a little 
unclear on it.

Thanks in advance for any answers you might have or documentation you 
could direct me to.  I've noted so far that this list has a high number 
of posts.  Good.  I need all the info I can get at the moment.  :)  I 
hope that soon I can contribute to this list, instead of being the 
problem child.  ;-)

Thanks!

Travis Beaty
Mason City, Iowa.







More information about the Python-list mailing list