Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

use decorator in class python

class Test(object):
    def _decorator(foo):
        def magic( self ) :
            print "start magic"
            foo( self )
            print "end magic"
        return magic

    @_decorator
    def bar( self ) :
        print "normal call"

test = Test()

test.bar()
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #decorator #class #python
ADD COMMENT
Topic
Name
8+4 =