29 Nov
2010
29 Nov
'10
1:44 a.m.
On Mon, 29 Nov 2010 00:37:12 +0200
cool-RR
`issubclass(1, list)` raises an Exception, complaining that `1` is not a class. This is wrong in my opinion. It should just return False.
It raises an exception for the same reason that 1 in 'a' raises an exception. Because there's no way that an int can belong in a string, or an int can be a subclass of anything; and so passing an int there is very likely to be a programming error. Python is dynamically typed, it doesn't mean it is untyped (contrast with PHP). If you want arbitrary polymorphism, you have to write the supporting code yourself. Regards Antoine.