a question about decorator

kyo guan kyoguan at gmail.com
Mon Oct 22 02:37:36 EDT 2007


Hi:

	please look at this code.

def A():
	print 'warp in A'
	def why(self, *arg, **kw):
		print 'in A'
		print self
		print arg
		print kw
		#self(*arg, **kw)
	
	return why
	
class T(object):
	@A()
	def test(g, out):
		print 'in test', out

it will out put:

warp in A
in A
<function test at 0x00BF0C70>
()
{}

the function why will be called, why? there is no code to call it.

Kyo.




More information about the Python-list mailing list