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

2008-10-09 Thread Nick Coghlan
Guido van Rossum wrote: > Well, I don't recall what CLPython is, but I believe it is broken and > that code should work -- there are (or used to be) examples of using > exec to populate classes in the standard library so while it may look > dodgy it really is exected to work... I think this behavi

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

2008-10-08 Thread Terry Reedy
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, prope

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

2008-10-08 Thread Guido van Rossum
Well, I don't recall what CLPython is, but I believe it is broken and that code should work -- there are (or used to be) examples of using exec to populate classes in the standard library so while it may look dodgy it really is exected to work... On Wed, Oct 8, 2008 at 4:40 PM, Ondrej Certik <[EMA

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

2008-10-08 Thread Ondrej Certik
Hi Terry, On Wed, Oct 8, 2008 at 9:17 PM, Terry Reedy <[EMAIL PROTECTED]> wrote: > Willem Broekema wrote: >> >> The issue came up while trying to get some Sympy code running on CLPython. >> >> class C: >> exec "a = 3" >> print locals() >> >> 1. Is it guaranteed that class C gets an attribute "a"

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

2008-10-08 Thread Terry Reedy
Willem Broekema wrote: The issue came up while trying to get some Sympy code running on CLPython. class C: exec "a = 3" print locals() 1. Is it guaranteed that class C gets an attribute "a", i.e. that the locals printed include {'a': 3}? 2. It it (also) guaranteed if it were in a function sco