encapsulating a global variable (BlindAnagram)

Christman, Roger Graydon dvl at psu.edu
Tue Feb 25 12:16:18 EST 2020


> On Tue, 25 Feb 2020 3:06 PM BlindAnagram <blindanagram at nowhere.com> wrote:

> My interest in this stems from wanting to keep the dictionary only
> available to the function that uses it and also a worry about being
> called from threaded code.

It seems like the simplest solution for this is to make
a completely new file (module) containing nothing but
the dictionary and this one function that uses it.
Then you can import the function from the module
wherever it is called without importing the dictionary.

The thing I find curious is that apparently no other
function is allowed to create or populate the dictionary
in the first place.   Is it practical to have the entire
dictionary statically defined?

Roger Christman
Pennsylvania State University


More information about the Python-list mailing list