in-module global variables
Aahz Maruch
aahz at panix.com
Thu Sep 28 14:16:56 EDT 2000
In article <mailman.970136624.1180.python-list at python.org>,
Matthew Banham <matb at photond.com> wrote:
>
>When writing a python module, how do I correctly declare a global variable-
>i.e. a variable that has scope throughout the whole of the module?
You cannot. You must explicitly declare that variable to be global
within each scope by using the "global" statement. I suggest instead
that you create a dictionary or class instance and modify its
attributes (mutable objects can be functionally global because you only
change their internal state, not the object reference itself).
--
--- Aahz (Copyright 2000 by aahz at pobox.com)
Androgynous poly kinky vanilla queer het <*> http://www.rahul.net/aahz/
Hugs and backrubs -- I break Rule 6
"Perhaps God rewards martyrs, but life seldom does..." --Ulrika O'Brien
More information about the Python-list
mailing list