Global variables for python applications

Steven D'Aprano steven at REMOVE.THIS.cybersource.com.au
Mon May 17 00:24:08 EDT 2010


On Mon, 17 May 2010 13:34:57 +1000, James Mills wrote:

> On Mon, May 17, 2010 at 11:57 AM, John Nagle <nagle at animats.com> wrote:
>>   For one thing, it's fine to share constants across threads, while
>> sharing globals is generally undesirable.  Also, more compile-time
>> arithmetic becomes possible.
>>
>>   Python does have a few built-in named unassignable constants:
>> "True", "None", "__debug__", etc.  "Ellipsis" is supposed to be a
>> constant, too, but in fact you can assign to it, at least through
>> Python 3.1.
>>
>>   I think there's some religious objection to constants in Python, but
>> it predated threading.
> 
> To be honest, classes work just fine for defining constants. (Though in
> my own code I use ALL UPPER CASE variables as it the style).


In what way are they constant? Can you not modify them and rebind them?


-- 
Steven



More information about the Python-list mailing list