Intercepting binding?

andrew cooke andrew at acooke.org
Wed Sep 23 22:41:25 EDT 2009


On Sep 23, 10:11 pm, Dave Angel <da... at ieee.org> wrote:
> This comes up periodically in this list, and the answer is always
> something like:  you can't get there from here.

Well, I'm both flexible and desperate, so this is a possible route
(perhaps near enough):


import sys

class Foo(object):

    def __rlshift__(self, name):
        try:
            raise Exception()
        except:
            locals = sys.exc_traceback.tb_frame.f_back.f_locals
            locals[name] = self

if __name__ == '__main__':
    foo = Foo()
    'a' << foo
    print(a)


andrew



More information about the Python-list mailing list