Can I, inside the decorator, refer to the name of the object being decorated? E.g.,
def add_debug_info(func):
# how to write magic_function?
name = magic_function(func)
# name is 'execute' when applied as
# @add_debug_info
# def execute():
I'm trying to print out debugging statements that incude this name, since I'm passing higher level functions around and it's hard to tell which function the debugging statement is referring to.
I'm only aware of one approach to get to the name of an object, but it doesn't work well here (multiple names can refer to an object, but I want the one specific name that happened to be decorated).