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 the docs ??? Hm, the documentation has an explicit warning:
http://docs.python.org/lib/built-in-funcs.html#l2h-47 """ locals( ) Update and return a dictionary representing the current local symbol table. Warning: The contents of this dictionary should not be modified; changes may not affect the values of local variables used by the interpreter. """ By the way, the local namespace is affected if you don't provide it explicitly: >>> def f(): ... exec "a=42" ... print a ... a = "whatever" ... >>> f() 42 Peter -- http://mail.python.org/mailman/listinfo/python-list