On Jul 31, 2:37 pm, "Delgado, Edgardo  CIV NAVAIR 4.1.4.3"
<[EMAIL PROTECTED]> wrote:
> Is there a way to create a shared object in python?
>
> Thx,
>
> Edgar

You can save variables in a separate module. Something like this
structure works quite well:

<code>
# shared.py
# shared variables / object
someNum = 0
</code>

<code>
# first module
import shared
x = shared.someNum
# do something
x = 5
</code>

<code>
# second module
import shared
y = shared.someNum
</code>

Basically as the code is called, be it a dialog from a main gui or
whatever, it updates this variable that is kind of held "out there" in
memory. Thus, it is available for and other running modules that
import it. It's kind of hard to get your mind around at first, but
I've used it before for some cool programming magic.

Mike

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to