decorator for a function without argument

rkmr.em at gmail.com rkmr.em at gmail.com
Tue Oct 23 01:27:06 EDT 2007


hi:
i have a decorator given below.
def checkdb(web):
        def decorator(func):
                def proxyfunc(self, args=(), kw=None):
                                #DO STUFF with web
                                return func(self, *args, **kw)
                return proxyfunc
        return decorator


but if i use it to decorate function without any arguments I get this error:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: proxyfunc() takes at least 1 argument (0 given)

how to fix this?
thanks
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20071022/55f0a1db/attachment.html>


More information about the Python-list mailing list