I would like to invoke the following code in-situ wherever I refer to MY_MACRO in my code below.
MY_MACRO
# MY_MACRO frameinfo = getframeinf
you could use function if you wanted to:
def MY_MACRO(): frame = currentframe() try: macro_caller_locals = frame.f_back.f_locals print(macro_caller_locals['a']) finally: del frame def some_function: a = 1 MY_MACRO()