reflection

C

carlo v. dango

hello there

I have searched the documentation in vein... :(

I would like to be able to

a) see all classes in the runing system

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
 
D

Duncan Booth

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)
 
C

carlo v. dango

Duncan Booth wrote:

many thanks for the input..


(e-mail address removed):

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,202
Messages
2,571,057
Members
47,662
Latest member
sxarexu

Latest Threads

Top