Feb. 10, 2013
9:59 p.m.
On 02/10/2013 01:46 PM, PJ Eby wrote:
How about you return FunctionType as your __class__ attribute? ;-)
Your type() will still be different, but isinstance() also considers the __class__ if it's different from the type(). (At least it does in 2.x, I've not tried it in any 3.x versions yet...)
Python 3.2.3 (default, Oct 19 2012, 19:53:16) [GCC 4.7.2] on linux2 Type "help", "copyright", "credits" or "license" for more information. --> class Test(): ... pass ... --> t = Test() --> t.__class__ <class '__main__.Test'> --> import types --> class Test(): ... __class__ = types.FunctionType ... --> t = Test() --> t.__class__ <class 'function'> --> isinstance(t, types.FunctionType) True -- ~Ethan~