Exec and Scope
prologic at shortcircuit.net.au
Fri Oct 31 04:56:02 CET 2008
Good lord man, what are you trying to solve ?
Describe your "actual problem" you're attempting
to solve... This looks really really ugly and I would
advise against any solution that relies on exec()
On Fri, Oct 31, 2008 at 1:47 PM, Emanuele D'Arrigo <manu3d at gmail.com> wrote:
> Hi everybody!
> I'm trying to do something in a way that is probably not particularly
> wise but at this point I don't know any better, so bear with me.
> Suppose in main.py I have the following statements:
> myObject = MyObject()
> Now suppose the method
> def execThis(aCommandInAString):
> is somewhere "far away" in terms of scope. Somewhere where the code
> doesn't know anything about the instance myObject and even less about
> its methods and attributes. How do I get myObject.myCommand() properly
> I'm guessing it's about taking a snapshot of or a reference to the
> namespace that is correct for the execution of the command, but... is
> that the case? And how do I get a handle to that?
> Thanks for your help!
-- "Problems are solved by method"
More information about the Python-list