You can't change a Python function's local variables from outsideJuly 13, 2007
In an aside in a recent entry, I wrote:
I'm wrong. In Python, no outside power can change a function's local
variables (more precisely, no outside power can change the name
bindings, doing the equivalent of ' Once I thought about it, this limitation is a logical consequence of how Python implements local variables. Since local variables aren't stored in a Python data structure, the CPython core would have to implement special functions to modify their values, which would only be useful for debuggers and people who want to commit dubious hacks. (This does mean that not even Python debuggers can change local variables, although not all of them will clearly tell you this.) |
These are my WanderingThoughts GettingAround This is part of CSpace, and is written by ChrisSiebenmann. * * * Atom feeds are available; see the bottom of most pages. Categories: links, linux, programming, python, snark, solaris, spam, sysadmin, tech, unix, web |