Intercepting binding?

andrew cooke andrew at acooke.org
Thu Sep 24 02:15:14 CEST 2009


This is a bit vague, I'm afraid, but is there any way for me to take
code like:

   a = Foo()
   beta = Bar()

and somehow attach the string "a" to the Foo instance and "beta" to
the Bar instance.  At some later point in the program I want to be
able to look at the Bar instance and say to the user "this was called
beta in your routine".

The motivation is debugging an embedded domain specific language and
the solution has to be cross platform for Python 3+ (bonus points for
Python 2 too).

Obviously I can parse the code, but I was wondering if there was some
other (no doubt terribly hacky) approach.  Even some idea of what to
google for would be a help...

Thanks,
Andrew



More information about the Python-list mailing list