[Python-ideas] Proposed additions to inspect module for function and generator state introspection
ncoghlan at gmail.com
Thu Sep 29 19:44:57 CEST 2011
Based on the testability comments in the closure threads, I created
http://bugs.python.org/issue13062 to propose two new introspection
Returns a dictionary mapping closure references from the supplied
function to their current values.
Returns the same result as would be reported by calling locals()
in the generator's frame of execution
The former would just involve syncing up the names on the code object
with the cell references on the function object, while the latter
would be equivalent to doing generator.gi_frame.f_locals with some
nice error checking for when the generator's frame is already gone (or
the supplied object isn't a generator iterator).
Nick Coghlan | ncoghlan at gmail.com | Brisbane, Australia
More information about the Python-ideas