completely implicit interpolation based on a frame object

Edward Peschko horos11 at gmail.com
Tue Dec 7 20:49:59 EST 2010


All,

Ok, it looks like in order to implement a tracer that does
interpolation, I'm going to have to hack around with frames.

Perl's interpolation is fairly straightforward, to do interpolation of
$a == 1 all you need to do is put quotes around "$a == 1" to have $a
evaluated.

So, I'd like to do the same thing with python. It looks like I can do
the same thing with frames, ie:

     interpolate_frame(frame, "if not wx.Platform == '__WXMAC' ")

would interpolate wx based off of the frame that you passed to
interpolate_frame, because wx is in the f_locals or f_globals
dictionary.

Hence, this would become:

    loc_wx = _first_defined(frame.f_locals["wx"],     frame.f_globals["wx"])
    return "if not ", loc_wx.Platform , " == \"__WXMAC\""

which would then do the interpolation.

I guess my question is - has something like this been released? I see
some close hits, namely Evan Forsmark's
http://www.evanfosmark.com/2008/06/string-interpolation-in-python/

but I don't see anything exact, and getting this right would be fairly
tricky, so I was hoping for canned solution.

Any ideas would be great on this, including pitfalls that people see
in implementing it.


Ed



More information about the Python-list mailing list