[Tutor] Re: Might be a silly question!

Jeffrey Maitland maitj at vianet.ca
Fri Feb 11 16:47:42 CET 2005

Thanks that's what I thought. 

Wasn't 100% sure that is what prompted me to ask the question in here. 

As for the CAPS thing for constants, I generally try and practice (to the 
best of my knowledge) proper programming consepts/styles/standards. However 
I have been reading code written before me (mind you it's C++) and the 
authors seemed to follow what ever style they wished to that day.  Oh well 
that's the nature of the beast. 

Thanks again for clearing that up for me. 


Bill Mill writes: 

> Jeff, 
> On Fri, 11 Feb 2005 10:03:30 -0500, Jeffrey Maitland <maitj at vianet.ca> wrote:
>> Hello all, 
>> I am drawing a blank right now and can't seem to find anything on it and I
>> am sure this issue has been addressed before, so here is the question. 
>> Can and if you can how do you set a variable as a constant? 
>> Example of what I mean: (this is loose and not python since variable type
>> declaration is not needed in python) 
>> CONST int gamma = 5 
>> This would mean in my little mind that the variable gamma which is an
>> integer of 5 can not be changed in the code and would throw an error if you
>> tried. Just wondering if there is a way of doing this in Python.
> There is no real way to guarantee this in Python. 
>>  This is
>> just to clear this up in my mind it means nothing to my code since the way I
>> write variable names any variable I want to remain unchanged I use caps to
>> help distinguish easily.
> Constants are enforced by convention in Python. Any variable with a
> name in ALL CAPS is considered to be a constant, and it is considered
> bad programming style to change it. While it sounds like a weak
> system, and I'm sure there have been problems with it, I've never
> heard of one. Remember to only import the names you need from the
> classes you import, and you should be fine. 
> Peace
> Bill Mill
> bill.mill at gmail.com

More information about the Tutor mailing list