How to Lock Globar Variables across Modules?

William Djaja Tjokroaminata billtj at
Thu Sep 28 15:46:49 CEST 2000

Alex <cut_me_out at> wrote:

:> In the main module, all the code will look like
:>     schedule (sv.current_time)
:> But the same code in other modules will have to look like
:>     schedule (
:> I want something that is consistent across all the simulation modules.

: Well, perhaps you could import the main_module into itself, so that you
: can refer to in there as well.  At least it'd be
: consistent. 

: Alex.

: -- 
: Speak softly but carry a big carrot.


I think there are two disadvantages of importing the main_module into
itself to make the code consistent:

    1) It is longer to type
    2) It is probably less efficient

In 1), typing '' is more tedious than just typing 'sv'.  I
wish python had some macro just like in C/C++ with its pre-processor:

    #define sv

The macro will solve the typing problem, but does not increase
efficiency.  I have read that every dot operator results in a dictionary
look-up.  Therefore I wish python had a reference feature to make it more

    sv& =

Whatever '' points to, 'sv' will also point to.  If
possible in the implementation, hopefully a reference like this will not
involve a dictionary look-up at all.

So for now I guess I have to live in the world that python has
defined.  Any possible way to express my wish list, to Guido maybe?

Thanks for all the reply.



More information about the Python-list mailing list