Is there a way to dereference a cell object (that is, get
the object that it references to) in Python?
[Background: a cell is an undefined internal implementation object used to
make nested scoping work as advertised. One might think of it as a means
for persisting cross-scope name-binding of objects in intermediate nested
scopes of nested functions. Alternatively, a cell is 'persistent read-only
shadow of an outer local'. For nested functions that access intermediate
locals, .func_closure is a tuple of 'cells'.]
Yes and no, depending on what you mean be 'dereference'. Within the nested
function, you 'dereference' the variable the same way you do any bound
ame -- write it! Outside the function, where the variable has no
conceptual existence, you can grab a cell from the func_closure tuple, but I
know of no way to access its value.