Re: Creating a shared object in python
- From: kyosohma@xxxxxxxxx
- Date: Tue, 31 Jul 2007 19:57:05 -0000
On Jul 31, 2:37 pm, "Delgado, Edgardo CIV NAVAIR 4.1.4.3"
<edgardo.delg...@xxxxxxxx> 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
.
- References:
- Creating a shared object in python
- From: Delgado, Edgardo CIV NAVAIR 4.1.4.3
- Creating a shared object in python
- Prev by Date: Re: Why no maintained wrapper to Win32?
- Next by Date: Re: zip() function troubles
- Previous by thread: Creating a shared object in python
- Next by thread: Re: Creating a shared object in python
- Index(es):