refer to self in a decorator on a class method

Yuccaplant pieter.cogghe at gmail.com
Mon Mar 29 05:39:05 EDT 2010


Hi all,

I would like to do something like this:

********************
class HelloWorld (object):

    def __init__(self,clk):
        self.clk = clk

    @always(self.clk.posedge)
    def sayHello(self):
        print "%s Hello World!" % now()
********************

Problem is however I can't refer to self in the decorator call. Is
there any workarround?

thanks a lot,

pieter



More information about the Python-list mailing list