How do I add a decorator to a method in python?

Posted by Timmy on Stack Overflow See other posts from Stack Overflow or by Timmy
Published on 2010-04-24T04:06:54Z Indexed on 2010/04/24 4:23 UTC
Read the original article Hit count: 242

Filed under:
|

How do I add a decorator to a method in a class? I tried

def add_decorator( cls ):
    @dec
    def update(self):
        pass

    cls.update = update

@dec did not apply to update

I'm trying to use this with orm.reconstructor in sqlalchemy.

© Stack Overflow or respective owner

Related posts about python

Related posts about decorator