Find subclasses of a class

Gerrit Holl gerrit at nl.linux.org
Fri Oct 3 16:05:20 EDT 2003


<quote name="soso" date="1065182524" email="soso_pub at yahoo.com">
> Is there a way to find out the subclasses of a class?
</quote>

Partially. Only if those subclasses have been accessed already:
22:04:47:0:gerrit at topjaklont:~$ python
Python 2.3 (#1, Aug  5 2003, 14:13:25)
[GCC 3.2.2 20030222 (Red Hat Linux 3.2.2-5)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
  0 >>> 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'>]
  1 >>> tuple.__bases__
(<type 'object'>,)
  2 >>> 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 'tuple'>]

Don't ask me why!

Gerrit.

-- 
Mozilla _is_ the web: it grows faster than you can download it.
1011001 1101111 1110101 1110010 1110011 0101100
1000111 1100101 1110010 1110010 1101001 1110100





More information about the Python-list mailing list