473,320 Members | 2,054 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Creating a shared object in python

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

Thx,

Edgar
Jul 31 '07 #1
3 4133
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Francisco Miguel Montenegro Montes | last post by:
Hi, perhaps some of you can help me... I'm installing Python 2.3 (in Linux RedHat 8.0) and I need to build it like a shared library, because I want to interact Python with PostgreSQL. Following...
2
by: Douglass Turner | last post by:
Hi, Please release me from my own private hell. Platform: SuSE 8.1 I'm installing python 2.3 tarball as follows: ../configure --enable-shared make
30
by: Sean R. Lynch | last post by:
I've been playing around with Zope's RestrictedPython, and I think I'm on the way to making the modifications necessary to create a capabilities-based restricted execution system. The idea is to...
3
by: Pro Grammer | last post by:
Hello, all, I am not sure if this is the right place to ask, but could you kindly tell me how to "load" a shared object (like libx.so) into python, so that the methods in the .so can be used? That...
5
by: Claudio Grondi | last post by:
Background information: --------------------------------- in order to monitor mainboard sensory data as fan speeds, temperatures, applications like SpeedFan http://www.almico.com/speedfan.php or...
2
by: vvenk | last post by:
Hello: I am thinking of an object called "user." This object will be instatntiated during a login process. But I want to use this to control the behavior of the application since it will also...
19
by: Dr Mephesto | last post by:
Hi! I would like to create a pretty big list of lists; a list 3,000,000 long, each entry containing 5 empty lists. My application will append data each of the 5 sublists, so they will be of...
5
by: Tim | last post by:
Hello Everyone, I am getting shared memory in python using the following. szName = c_char_p(name) hMapObject = windll.kernel32.CreateFileMappingA(INVALID_HANDLE_VALUE, None, PAGE_READONLY, 0,...
0
by: abarun22 | last post by:
HI I am new to SWIG & Python and right now i am in the process of wrapping some "C" functionalities present in a static library for python. I do have my C file "name.c" which just contains some...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.