Is it possible in Python to get some abstract representation of a variable, given FrameInfo
and location (line number and offset) of its identifier occurrence?
What I’d like to be able to do with it is change its value, find its definition site and all occurrences (which may form a proper subset of the occurrences of this identifier in the code associated with the frame), ideally also dynamically create a closure closing over it.
It’s like what the ast
module does, but enhanced with some rudimentary semantics. The interpreter already has to figure it out anyway, so maybe there’s a way to get at it from within the programme.