I have a decorator function that uses sys._getframe(1).f_code to get the code object of the caller func.
The problem is that I need the caller func function object so I can access this functions attributes.
I can use eval to call the function with the code object but that does not help me.
def decorator(func)
def wrappe_function(*args, **kwargs):
# Problem here, want func object not code object
result = getattr(sys._getframe(1).f_code, "level")
if result != "private":
print "Warning accessing a private func. If this funcion is changed, you will not be notified!"
return func(*args, **kwargs)
return decorator
@decorator
def x():
print "hello"
def main()
x()
main.level = "public"