completely implicit interpolation based on a frame object

Discussion in 'Python' started by Edward Peschko, Dec 8, 2010.

  1. 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
    Edward Peschko, Dec 8, 2010
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. markla
    Replies:
    1
    Views:
    532
    Steven Cheng
    Oct 6, 2008
  2. Replies:
    2
    Views:
    298
    sebastian
    Mar 28, 2009
  3. Replies:
    4
    Views:
    289
    JosephKK
    Apr 2, 2009
  4. Sven Suska
    Replies:
    4
    Views:
    150
    Sven Suska
    May 28, 2007
  5. Replies:
    2
    Views:
    224
Loading...

Share This Page