how to create a pointer, or is there a better solution ?

S

stef mientki

hello,

I've a program where users can make modules,
by just dumping them in a certain directory,
then they will dynamically link into the program if needed.

One of the communication channels I use,
is a general global file, which should be imported by all user modules.

One of the things a user should be able to do is to create " global
variables",
which should then be available in all the other program modules.
So the global file contains a list, call JAL_Globals = [],
where each user can append the globals he want to be exposed to the
outside world (for read only).
Now if these globals are complex items, no problem, I get pointers and
can access them.
But if these variables are simple, like integers, I get the value only
once ;-)

How can I create of dynamic pointers, even to simple variables ?
Or is there a better way ?

thanks,
Stef Mientki
 
D

Diez B. Roggisch

stef said:
hello,

I've a program where users can make modules,
by just dumping them in a certain directory,
then they will dynamically link into the program if needed.

One of the communication channels I use,
is a general global file, which should be imported by all user modules.

One of the things a user should be able to do is to create " global
variables",
which should then be available in all the other program modules.
So the global file contains a list, call JAL_Globals = [],
where each user can append the globals he want to be exposed to the
outside world (for read only).
Now if these globals are complex items, no problem, I get pointers and
can access them.
But if these variables are simple, like integers, I get the value only
once ;-)

How can I create of dynamic pointers, even to simple variables ?
Or is there a better way ?

Don't use a list, use a dictionary that has names mapped to values. Then
the problem goes away, because instead of mutating an object (which you
still can do), you can also rebind a new one -e.g like this:


JAL_Globals['name'] += 100

Diez
 

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

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,065
Latest member
OrderGreenAcreCBD

Latest Threads

Top