[Python-Dev] Why does Signature.from_function() have to check the type of its argument?
Ethan Furman
ethan at stoneleaf.us
Sun Feb 10 22:59:50 CET 2013
More information about the Python-Dev mailing list
Sun Feb 10 22:59:50 CET 2013
- Previous message: [Python-Dev] Why does Signature.from_function() have to check the type of its argument?
- Next message: [Python-Dev] Why does Signature.from_function() have to check the type of its argument?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
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~
- Previous message: [Python-Dev] Why does Signature.from_function() have to check the type of its argument?
- Next message: [Python-Dev] Why does Signature.from_function() have to check the type of its argument?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-Dev mailing list