Is it possible to find out if a function is decorated at runtime? For example could I find all functions in a module that are decorated by “example”?
@example
def test1():
print "test1"
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
In the general case it is not possible because the
exampledecorator might not leave any trace that’s detectable at runtime — for example, it could beIf you do control the source for
example, it’s of course easy to make it mark or record the functions it’s decorating; if you don’t, it may be utterly impossible to do what you want.