[Pyrex] Using eval in Pyrex

Greg Ewing greg.ewing at canterbury.ac.nz
Wed Oct 17 05:26:22 CEST 2007


Jim Kleckner wrote:
> I ported some Python code that uses eval to programmatically access 
> local variables and obviously it breaks.  What approach would you recommend?

Keep the relevant variables in a dict and pass it
in to eval as an explicit namespace.

It's completely impossible to get eval to access
the real locals of a Pyrex function, since they're
C variables living in a C stack frame.

-- 
Greg Ewing, Computer Science Dept, +--------------------------------------+
University of Canterbury,	   | Carpe post meridiem!          	  |
Christchurch, New Zealand	   | (I'm not a morning person.)          |
greg.ewing at canterbury.ac.nz	   +--------------------------------------+



More information about the Pyrex mailing list