[Python-Dev] Should issubclass() be more like isinstance()? (original) (raw)
Georg Brandl g.brandl at gmx.net
Wed Apr 5 08:49:59 CEST 2006
- Previous message: [Python-Dev] Should issubclass() be more like isinstance()?
- Next message: [Python-Dev] Reminder: TRUNK FREEZE. 2.5a1, 00:00 UTC, Wednesday 5th of April.
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Crutcher Dunnavant wrote:
While nocking together a framework today, I ran into the amazing limitations of issubclass().
A) issubclass() throws a TypeError if the object being checked is not a class, which seems very strange. It is a predicate, and lacking a isclass() method, it should just return False. B) issubclass() won't work on a list of classs, the way isinstance() does. Is there any support for patches which fix A and/or B?
I don't think B is broken:
Python 2.4.2 [...]
issubclass(int, 0) Traceback (most recent call last): File "", line 1, in ? TypeError: issubclass() arg 2 must be a class or tuple of classes issubclass(int, (int, str)) True issubclass(str, (int, str)) True issubclass(dict, (int, str)) False
(both isinstance() and issubclass() don't work on a list as second argument)
Georg
- Previous message: [Python-Dev] Should issubclass() be more like isinstance()?
- Next message: [Python-Dev] Reminder: TRUNK FREEZE. 2.5a1, 00:00 UTC, Wednesday 5th of April.
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]