HN2new | past | comments | ask | show | jobs | submitlogin

You can even hack it into a string class if you don't mind using even more scary hacks like monkey patching built in classes.

    def I(s):
        import inspect
        frame = inspect.currentframe()
        caller_locals = frame.f_back.f_locals
        return s.format(**caller_locals)

    def main():
        a = 12
        b = 10
        print I('A is {a} and B is {b}')

    if __name__ == '__main__':
        main()


Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: