Hi all! I am pretty new to Python, so please excuse me if I am missing something. Lately, I've been playing with decorators and I am a bit confused about some behavior. Here is the code that puzzles me:
in python shell: def function(): pass class A(object): def method(self): pass from types import MethodType from types import FunctionType if type(function) is FunctionType: print "this is what I expect" if type(A.method) is MethodType: print "this is what I expect" so far so good... everything seems logical. But if a decorator is declared things are becoming different: def deco(function): if type(function) is MethodType: print "MethodType" elif type(function) is FunctionType: print "FunctionType" @deco def function2(): pass # ==> this prints out FunctionType (oke) class A(object): @deco def method(self): pass # ==> this prints out FunctionType (???) Can somebody shed some light on why I am seeing this? (Using Python 2.5.1 on Win XP). TIA, ./alex -- .w( the_mindstorm )p. -- http://mail.python.org/mailman/listinfo/python-list