[Tutor] Re: [Pythonmac-SIG] Weird import problem with PythonIDE on Mac (was 'import problem')

Max Noel maxnoel_fr at yahoo.fr
Fri Apr 22 17:00:23 CEST 2005

On Apr 22, 2005, at 11:41, Chris Smith wrote:

> Do you have a suggestion as to what can I give a module so it has 
> enough information to execute a function that resides in __main__? 
> Here is a visual of what is going on:
> ------__main__
> def y1():
>   pass
> import foo
> foo.run(string_from_main) #what should I pass?
> ------external module, foo
> def run(string_from_main):
> 	#
> 	exec(string_from_main) #y1 is run as if it were in __main__
> /c

	Python makes it easy to do because functions (and classes) are 
objects. Here:

# in __main__
def y1():
import foo

# in foo
def run(functionFromMain):

-- Max
maxnoel_fr at yahoo dot fr -- ICQ #85274019
"Look at you hacker... A pathetic creature of meat and bone, panting 
and sweating as you run through my corridors... How can you challenge a 
perfect, immortal machine?"

More information about the Tutor mailing list