interaction between modules... globals?
Robin Becker
robin at jessikat.demon.co.uk
Wed Jul 7 08:45:03 EDT 1999
In article <19990707100532.A951 at optiplex.palga.uucp>, Gerrit Holl
<gerrit.holl at pobox.com> writes
>Hello,
>
>I have a program which consists of several little modules, but I encounter a
>problem with that. I have one module which returns a class instance, with
>messages as members, either Dutch or English. Every module needs that instance,
>but I don't want to pass it as an argument to every little function, the
>modules should find out theirselves. But I _also_ don't want to make that
>instance 5 times.
>
>So I thougt: I need a sort of global between the modules. Is this possible?
>
...
>regards,
>Gerrit.
>
I guess you need a singleton class. There was a c.l.p thread about this
recently.
I suggest something of the form
_LangGlobal=None
def getMessages():
global _LangGlobal
if _LangGlobal is None:
# calculate which language
#...
#...
_LangGlobal=result
return _LangGlobal
--
Robin Becker
More information about the Python-list
mailing list