Keeping track of subclasses and instances?
Thomas Heller
theller at ctypes.org
Thu Oct 11 02:30:02 EDT 2007
Karlo Lozovina schrieb:
> Hi,
>
> 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.
>>> object.__subclasses__()
[<type 'type'>, <type 'weakref'>, <type 'int'>, <type 'basestring'>, <type 'list'>, <type 'NoneType'>, ...
>>>
No builtin mechanism for instances exists, afaik.
Thomas
More information about the Python-list
mailing list