[Python-Dev] Why does Signature.from_function() have to check the type of its argument? (original) (raw)
Ethan Furman ethan at stoneleaf.us
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 ]