[Tutor] help needed with using exec

André Roberge andre.roberge at ns.sympatico.ca
Thu Nov 11 21:54:04 CET 2004


Dear Tutors,

Suppose I have in file test.py a single line:
move()

which is a function define in otherApp.py

After reading the content of  "test.py" into
the string named code, I would like to do

"exec code"

and have it execute move() as it is defined
in otherApp from myApp

Within myApp, I have
instance = otherApp()

I have tried hardcoding the following in myApp:
==
move = instance.move
move()
==
and it workd.

I then tried
==
exec code
==
by itself and it didn't work.
I also tried
==
exec code in myApp.__dict__
==
and it didn't work either.

Suggestions would be greatly appreciated.

André



More information about the Tutor mailing list