completely implicit interpolation based on a frame object

E

Edward Peschko

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,756
Messages
2,569,534
Members
45,007
Latest member
OrderFitnessKetoCapsules

Latest Threads

Top