Python Global State
er
erobererunc at gmail.com
Tue Feb 3 14:10:18 EST 2009
That was my hack for one other app, but I did it because I'd only been
studying Python for a month or two. Glad to see others did it once as well,
but that we all wised up. =P
It might be nice if Python could provide a global dictionary, perhaps _G{},
where you can throw things. This is actually the solution provided by the
Lua scripting language. Thanks for the global_ module solution, I was just
making sure that was the canonical way.
On Tue, Feb 3, 2009 at 1:27 PM, <rdmurray at bitdance.com> wrote:
> Quoth MRAB <google at mrabarnett.plus.com>:
> > er wrote:
> > > Simple question, I think: Is there a way to make a completely global
> > > variable across a slew of modules? If not, what is the canonical
> > > way to keep a global state? The purpose of this is to try to prevent
> > > circular module imports, which just sort of seems nasty. Thank you!
> > >
> > Simple answer: no.
>
> I'm wondering a little about posting this, but...well, the answer actually
> isn't "no". It's just that it's not something you should _ever_ do.
> The trick is to assign the value to the __builtins__ module...
>
> --RDM
>
> PS: I know this because Zope used to do it. Fortunately they wised
> up and refactored that code to be more sane.
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20090203/474e4a1e/attachment-0001.html>
More information about the Python-list
mailing list