On Sun, May 11, 2014 at 1:17 PM, Steven D'Aprano <steve+comp.lang.pyt...@pearwood.info> wrote: > But that is an implementation detail. IronPython and Jython use an > ordinary dict for local variable namespaces, just like globals. Consider > this example from Jython: > >>>> spam = 9999 >>>> def modify(namespace): > ... namespace['spam'] = 42 > ... >>>> def demo(): > ... modify(locals()) > ... spam = spam > ... return spam > ... >>>> demo() > 42
All you're proving here is that, in some Pythons, locals() is writeable. What happens if you remove the "spam = spam" line? Would demo() not then return spam from the global scope, because the variable does not exist at local scope? Every example you've shown is simply giving a value to something that you've created by the normal method of having an assignment inside the function. ChrisA -- https://mail.python.org/mailman/listinfo/python-list