Values and objects
Chris Angelico
rosuav at gmail.com
Sat May 10 23:30:03 EDT 2014
More information about the Python-list mailing list
Sat May 10 23:30:03 EDT 2014
- Previous message (by thread): Values and objects
- Next message (by thread): Values and objects
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On Sun, May 11, 2014 at 1:17 PM, Steven D'Aprano <steve+comp.lang.python at 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
- Previous message (by thread): Values and objects
- Next message (by thread): Values and objects
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list