Adding Macros to Python
问题 I would like to invoke the following code in-situ wherever I refer to MY_MACRO in my code below. # MY_MACRO frameinfo = getframeinfo(currentframe()) msg = 'We are on file ' + frameinfo.filename + ' and line ' + str(frameinfo.lineno) # Assumes access to namespace and the variables in which `MY_MACRO` is called. current_state = locals().items() Here is some code that would use MY_MACRO : def some_function: MY_MACRO def some_other_function: some_function() MY_MACRO class some_class: def some