Issue749480
This issue tracker has been migrated to GitHub,
and is currently read-only.
For more information,
see the GitHub FAQs in the Python's Developer Guide.
Created on 2003-06-05 11:30 by gerrit, last changed 2022-04-10 16:09 by admin. This issue is now closed.
Messages (3) | |||
---|---|---|---|
msg16259 - (view) | Author: Gerrit Holl (gerrit) | Date: 2003-06-05 11:30 | |
I am not entirely sure whether this is a bug, because I can't find documentation on __subclasses__ and am unable to read the source (don't know C). But the name __subclasses__ implies that a collection of all subclasses would be returned; however, it doesn't on my system. It seems as if some subclasses are only listed *after* they have been looked up in the subclasses' __bases__, while others are included without that: $ python Python 2.3b1+ (#2, Jun 4 2003, 17:16:59) [GCC 3.2.2 20030222 (Red Hat Linux 3.2.2-5)] on linux2 Type "help", "copyright", "credits" or "license" for more information. 0 >>> float in object.__subclasses__() False 1 >>> object in float.__bases__ True 2 >>> float in object.__subclasses__() True 3 >>> object.__subclasses__ <built-in method __subclasses__ of type object at 0x8107d60> 4 >>> object.__subclasses__() [<type 'type'>, <type 'int'>, <type 'basestring'>, <type 'list'>, <type 'NoneType'>, <type 'NotImplementedType'>, <type 'module'>, <type 'zipimport.zipimporter'>, <type 'posix.stat_result'>, <type 'posix.statvfs_result'>, <type 'dict'>, <type 'function'>, <type 'file'>, <type 'float'>, <type 'dictproxy'>] 5 >>> long in object.__subclasses__() False 6 >>> long() 0L 7 >>> long in object.__subclasses__() False 8 >>> long.__bases__ (<type 'object'>,) 9 >>> long in object.__subclasses__() True $ python -c "print object.__subclasses__()" [<type 'type'>, <type 'int'>, <type 'basestring'>, <type 'list'>, <type 'NoneType'>, <type 'NotImplementedType'>, <type 'module'>, <type 'zipimport.zipimporter'>, <type 'posix.stat_result'>, <type 'posix.statvfs_result'>, <type 'dict'>, <type 'function'>, <type 'file'>] $ python -S -c "print object.__subclasses__()" [<type 'type'>, <type 'int'>, <type 'basestring'>, <type 'list'>, <type 'NoneType'>, <type 'NotImplementedType'>, <type 'module'>, <type 'zipimport.zipimporter'>, <type 'function'>, <type 'posix.stat_result'>, <type 'posix.statvfs_result'>, <type 'dict'>] |
|||
msg16260 - (view) | Author: Gerrit Holl (gerrit) | Date: 2003-06-05 11:36 | |
Logged In: YES user_id=13298 I accidently pressed enter to early, here is some more information: $ python2.2 -S -c "print object.__subclasses__()" [<type 'type'>, <type 'list'>, <type 'NoneType'>, <type 'NotImplementedType'>, <type 'module'>] |
|||
msg16261 - (view) | Author: Martin v. Löwis (loewis) * | Date: 2003-06-14 14:28 | |
Logged In: YES user_id=21627 This is not a bug. A type is added to __subclasses__ of its base once it gets "readied". When and if that happens for a certain type is implementation-defined. |
History | |||
---|---|---|---|
Date | User | Action | Args |
2022-04-10 16:09:02 | admin | set | github: 38594 |
2003-06-05 11:30:32 | gerrit | create |