I wrote a function decorator like this:

def tsfunc(func):
    def wrappedFunc():
        print '%s() called' % func.__name__
        return func()
    return wrappedFunc()

@tsfunc
def foo():
    pass

foo()  # to get it work, use foo instead of foo()
foo()

I got following error message:

foo() called
Traceback (most recent call last):
  File "decorator.py", line 11, in <module>
    foo()
TypeError: 'NoneType' object is not callable

I get it work by replacing "foo()" with "foo". but I still didn't get the result I expected:

foo() called

seems like the foo function is only called once.

Please help me understand why this is happening.

Edit
Report