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~
_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe:
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com