module global variables

P

pistacchio

hi to all!
can i load a module passing to it, automatically and as default, all
the caller's global variables to act as module's global variables?
thanks
 
A

alex23

hi to all!
can i load a module passing to it, automatically and as default, all
the caller's global variables to act as module's global variables?
thanks

module = __import__('module', globals=globals())

I think that's what you're looking for.

- alex23
 
P

pistacchio

module = __import__('module', globals=globals())

I think that's what you're looking for.

- alex23


hmm, well, maybe yes.. should i ovveride the standard import function
of the module?
say that the module is called "pycatrix", would adding this to the
module solve the problem?

def __import__('pycatrix', globals=globals()):
 
P

pistacchio

hmm, well, maybe yes.. should i ovveride the standard import function
of the module?
say that the module is called "pycatrix", would adding this to the
module solve the problem?

def __import__('pycatrix', globals=globals()):

pardon, this:
def __import__('pycatrix', globals=globals()):
pass
 
M

Marco Mariani

Are you positively sure you need this?

Modifying imported modules is already quite fragile, but this.. it's
basically a reversed(import *)

It's quite messy. Where quite equals to "very"
 
P

pistacchio

Are you positively sure you need this?

Modifying imported modules is already quite fragile, but this.. it's
basically a reversed(import *)

It's quite messy. Where quite equals to "very"

well, i'm writing a module called pycatrix. within the module i have
compile / exec statements in a functions that work on global
variables. ( exec compiledTemplate in globals() ).

now, i don't want to be forced (or force the end user) to import to
call the module's function with a compulsory "globals()" as argument.
 
P

pistacchio

well, i'm writing a module called pycatrix. within the module i have
compile / exec statements in a functions that work on global
variables. ( exec compiledTemplate in globals() ).

now, i don't want to be forced (or force the end user) to import to
call the module's function with a compulsory "globals()" as argument.

up
 

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,792
Messages
2,569,639
Members
45,351
Latest member
RoxiePulli

Latest Threads

Top