Creating a shared object in python

  • Thread starter Delgado, Edgardo CIV NAVAIR 4.1.4.3
  • Start date
D

Delgado, Edgardo CIV NAVAIR 4.1.4.3

Is there a way to create a shared object in python?

Thx,

Edgar
 
K

kyosohma

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
 
F

Fabio Z Tessitore

Il Tue, 31 Jul 2007 15:37:26 -0400, Delgado, Edgardo CIV NAVAIR 4.1.4.3
ha scritto:
Is there a way to create a shared object in python?

Thx,

Edgar

Usually object are shared in Python. i.e.

# a list
l = [ 1 , 2 , 3 ]

# a list containing l
m = [ l, 4, 5 ] # now m is [ [1,2,3] , 4 , 5 ]

# ok, let's change l
l[0] = 10

# now m is changed
# NOW m is [ [10,2,3] , 4 , 5 ]
 
B

Bjoern Schliessmann

Delgado said:
Is there a way to create a shared object in python?

What's a shared object? Do you mean IPC or .so libraries, or
something different?

Regards,


Björn
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,773
Messages
2,569,594
Members
45,119
Latest member
IrmaNorcro
Top