By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,923 Members | 1,443 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,923 IT Pros & Developers. It's quick & easy.

Creating a shared object in python

P: n/a
Is there a way to create a shared object in python?

Thx,

Edgar
Jul 31 '07 #1
Share this Question
Share on Google+
3 Replies


P: n/a
On Jul 31, 2:37 pm, "Delgado, Edgardo CIV NAVAIR 4.1.4.3"
<edgardo.delg...@navy.milwrote:
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

Jul 31 '07 #2

P: n/a
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 ]
Jul 31 '07 #3

P: n/a
Delgado, Edgardo CIV NAVAIR 4.1.4.3 wrote:
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

--
BOFH excuse #404:

Sysadmin accidentally destroyed pager with a large hammer.

Jul 31 '07 #4

This discussion thread is closed

Replies have been disabled for this discussion.