Hi all,
given the following code:
---
def append(method,b ottom):
def wrapped(*args, **kwargs):
res = method(*args, **kwargs)
return bottom(res,*arg s, **kwargs)
setattr(method. im_class,method .__name__,wrapp ed)
def prepend(method, top):
def wrapped(*args, **kwargs):
top(*args, **kwargs)
return method(*args, **kwargs)
setattr(method. im_class,method .__name__,wrapp ed)
def test():
class C:
def f(self):
print "f"
def pre(self):
print "pre"
def post(res,self):
print "post"
prepend(C.f,pre )
append(C.f,post )
C().f()
---
how comes that test() only outputs:
pre
f
rather than what I expected:
pre
f
post
Thanks very much in advance,
cheers,
Nicolas
given the following code:
---
def append(method,b ottom):
def wrapped(*args, **kwargs):
res = method(*args, **kwargs)
return bottom(res,*arg s, **kwargs)
setattr(method. im_class,method .__name__,wrapp ed)
def prepend(method, top):
def wrapped(*args, **kwargs):
top(*args, **kwargs)
return method(*args, **kwargs)
setattr(method. im_class,method .__name__,wrapp ed)
def test():
class C:
def f(self):
print "f"
def pre(self):
print "pre"
def post(res,self):
print "post"
prepend(C.f,pre )
append(C.f,post )
C().f()
---
how comes that test() only outputs:
pre
f
rather than what I expected:
pre
f
post
Thanks very much in advance,
cheers,
Nicolas
Comment