reflection
carlo v. dango
dango at inc.com
Mon Jul 5 13:48:35 EDT 2004
Duncan Booth wrote:
many thanks for the input..
> "carlo v. dango" <dango at inc.com> wrote in news:77rbr1-
> 175.ln1 at gatekeeper.kadnet.dk:
>
>
>>hello there
>>
>>I have searched the documentation in vein... :(
>>
>>I would like to be able to
>>
>>a) see all classes in the runing system
>
>
> New style classes:
>
> def allclasses():
> klasses = { }
> work = [ object ]
> while work:
> aType = work.pop()
> if aType not in klasses:
> klasses[aType] = None
> work.extend(type.__subclasses__(aType))
> return klasses.keys()
>
> print allclasses()
>
> Or for all classes, new and old:
>
> import gc, types
> for o in gc.get_objects():
> if type(o) in (type, types.ClassType):
> print repr(o)
>
>
>>b) inspect all classse that can be found in pythonpath (to look for
>>classes not yet made instances of / loaded)
>>
>>
>>how to perform these simple tasks?
>>
>>sincerely
>> Carlo
>
>
More information about the Python-list
mailing list