From: ken at _nospam_ken.x13.com (Ken Kinder)
Date: Tue, 25 May 1999 22:49:42 -0600
Subject: Quick question: forcing exec() within a specific namespace
References: <Pine.GSO.3.95q.990520111058.22143A-100000@rac9.wam.umd.edu>
Message-ID: <374B7D66.7CCAAA17@_nospam_ken.x13.com>
X-UID: 1824                                                 

Sarino Suon wrote:
> 
> In the interactive interpreter, when I call exec(), whatever objects are
> created belong to the __main__ module. What if I need the objects to be
> attached to a specific object, such as a class instance? Can this be done?
> 
>                                                         --- Sarino

Yeah, it can.  Here's how it works: exec(code, [, globals [, locals ] ])

Globals and locals are namespaces, in dictionary form.  By default, the
name space of the calling code is used.




