git.net

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

encapsulating a global variable (BlindAnagram)


> 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