== You can't change a Python function's local variables from outside In an aside in a [[recent entry AssignmentInConditionals]], I wrote: > With sufficient cleverness, you can construct a version of _capture()_ > that is passed _store_'s name and puts the result in it directly, > without needing you to make it an array and use _store[0]_. 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 WhatVariablesMean]], doing the equivalent of '_localvar = something_'). While you can make a version of _capture()_ that sets global variables, setting a local variable in the function that called it is beyond its power. Once I thought about it, this limitation is a logical consequence of [[how Python implements local variables WhyLocalVarsAreFast]]. 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.)