KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
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.
Tags (comma-separated)
Save Edits
Cancel