OiO.lk Community platform!

Oio.lk is an excellent forum for developers, providing a wide range of resources, discussions, and support for those in the developer community. Join oio.lk today to connect with like-minded professionals, share insights, and stay updated on the latest trends and technologies in the development field.
  You need to log in or register to access the solved answers to this problem.
  • You have reached the maximum number of guest views allowed
  • Please register below to remove this limitation

Get variable from identifier in a context

  • Thread starter Thread starter ByteEater
  • Start date Start date
B

ByteEater

Guest
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.
<p>Is it possible in Python to get some abstract representation of a variable, given <code>FrameInfo</code> and location (line number and offset) of its identifier occurrence?</p>
<p>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.</p>
<p>It's like what the <code>ast</code> 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.</p>
 

Latest posts

Online statistics

Members online
1
Guests online
4
Total visitors
5
Top