[Python-Dev] effect of "exec" on local scope

Terry Reedy tjreedy at udel.edu
Thu Oct 9 05:18:13 CEST 2008

Ondrej Certik wrote:

> Which works in CPython but fails in CLPython. From your answer it
> seems to me that this code is not nice and we should not use it and
> should rather use something like:
> class Basic(AssumeMeths):
>   ...
> for k in AssumeMeths._assume_defined:
>   setattr(Basic, 'is_%s' % k, property(make__get_assumption('Basic', '%s' % k)))
> which should work on all platforms. What do you think?

That is what setattr is for.  Many consider exec a last resort.  I think 
any further discussion should move to the general python list or c.l.p 
since this is not a develop-core-python issue.

More information about the Python-Dev mailing list