Global variables for python applications
John Nagle
nagle at animats.com
Sun May 16 21:57:15 EDT 2010
James Mills wrote:
> The only place global variables are considered somewhat "acceptable"
> are as constants in a module shared as a static value.
Python really ought to have named constants.
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.
John Nagle
More information about the Python-list
mailing list