try something like this
def foo(): try: foo.called except: print "called" foo.called = True
methods and functions are objects. You can add methods and attributes to them. This may be useful for your business. If you want a decorator, just ask the decorator to highlight this method, but first check the flag. If the flag is found, the null method is returned and therefore executed.
source share