469,902 Members | 1,966 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,902 developers. It's quick & easy.

reflection

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
Jul 18 '05 #1
3 1785
carlo v. dango wrote:
hello there

I have searched the documentation in vein... :(
Well, then, I guess it's time to try an artery :-)
When I typed "python introspection" into Google, my first result was:

http://www-106.ibm.com/developerwork...y/l-pyint.html

which seems to be a nice introduction to the topic.

-Dan

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

Jul 18 '05 #2
"carlo v. dango" <da***@inc.com> wrote in news:77rbr1-
17*****@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


Jul 18 '05 #3
Duncan Booth wrote:

many thanks for the input..
"carlo v. dango" <da***@inc.com> wrote in news:77rbr1-
17*****@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



Jul 18 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by A. Wiebenga | last post: by
3 posts views Thread by HL | last post: by
9 posts views Thread by Kuberan Naganathan | last post: by
17 posts views Thread by raylopez99 | last post: by
reply views Thread by Gustavo Arriola | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.