All pastes #84553 Raw Edit

Untitled

public text v1 · immutable
·published 2006-07-11 01:48 UTC
rendered paste body
class logger:
    def __init__(self, c):
        self.c = c
    def __call__(self, *args, **kwds):
        print "Calling", self.c
        return self.c(*args, **kwds)

class callcounter:
    def __init__(self, c):
        self.c = c
        self.count = 0
    def __call__(self, *args, **kwds):
        self.count += 1
        return self.c(*args, **kwds)

@callcounter
@logger
def hehe():
    pass

hehe()
hehe()
print hehe.count