Re: problem with exec and locals()

2008-07-11 Thread Gabriel Genellina
En Fri, 11 Jul 2008 03:51:39 -0300, Uwe Schmitt <[EMAIL PROTECTED]> escribi�: On 1 Jul., 15:15, Mel <[EMAIL PROTECTED]> wrote: rocksportrockerwrote: > the following code does not work until I ommit the "a=0" statement. >    def test(): >        exec "a=3" in locals() >        print a >    

Re: problem with exec and locals()

2008-07-11 Thread Peter Otten
Uwe Schmitt wrote: >> Apparently, exec in locals() knows nothing about slots (because locals() >> is the only dictionary in the universe where slots would be involved ? -- >> perhaps not, but close). >> >> Mel. > > Thanks for your answer. I wonder if this is a bug, or did I miss > something in th

Re: problem with exec and locals()

2008-07-10 Thread Uwe Schmitt
On 1 Jul., 15:15, Mel <[EMAIL PROTECTED]> wrote: > rocksportrockerwrote: > > > Hi, > > > the following code does not work until I ommit the "a=0" statement. > > >    def test(): > >        exec "a=3" in locals() > >        print a > >        a=0 > > >     test() > > > print raises: > >      Unbound

Re: problem with exec and locals()

2008-07-01 Thread Mel
rocksportrocker wrote: > > Hi, > > the following code does not work until I ommit the "a=0" statement. > > >def test(): >exec "a=3" in locals() >print a >a=0 > > test() > > print raises: > UnboundLocalError: local variable 'a' referenced before > assignme

problem with exec and locals()

2008-07-01 Thread rocksportrocker
Hi, the following code does not work until I ommit the "a=0" statement. def test(): exec "a=3" in locals() print a a=0 test() print raises: UnboundLocalError: local variable 'a' referenced before assignment Can anybody explain what is going wrong here ? Gree