Keeping track of subclasses and instances?
theller at ctypes.org
Thu Oct 11 08:30:02 CEST 2007
Karlo Lozovina schrieb:
> what's the best way to keep track of user-made subclasses, and instances of
> those subclasses? I just need a pointer in a right direction... thanks.
New style classes have a __subclasses__ class method that shows the direct subclasses:
Python 2.4.4 (#71, Oct 18 2006, 08:34:43) [MSC v.1310 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
[<type 'type'>, <type 'weakref'>, <type 'int'>, <type 'basestring'>, <type 'list'>, <type 'NoneType'>, ...
No builtin mechanism for instances exists, afaik.
More information about the Python-list