By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,965 Members | 1,450 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,965 IT Pros & Developers. It's quick & easy.

Listing subtypes

P: n/a
Hi,

I remember seeing an easy way to list all subtypes of a specific type
but I haven't been able to find it anymore. What I am trying to do is
this: Given a class, get a list of all classes that derive from it.
Pretty much like __mro__ but downwards rather then upwards. Any ideas?

-Samuel
Nov 28 '07 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Ben Finney schrieb:
Samuel <kn******@gmail.comwrites:
>I remember seeing an easy way to list all subtypes of a specific type
but I haven't been able to find it anymore. What I am trying to do is
this: Given a class, get a list of all classes that derive from it.
Pretty much like __mro__ but downwards rather then upwards. Any ideas?

A class knows its parents; it doesn't know its children. (Or, in other
words, children need to know who their parents are, but aren't
required to notify their parents about anything.)
Not right. These special children are under a more demanding goverment.
class A(object):
pass

class B(A):
pass

print A.__subclasses__()
http://www.mail-archive.com/py******.../msg67979.html
Diez
Nov 29 '07 #2

P: n/a
On Nov 29, 1:54 am, "Diez B. Roggisch" <de...@nospam.web.dewrote:
print A.__subclasses__()
Ah, I knew I had seen this before. Thanks!

-Samuel
Nov 29 '07 #3

This discussion thread is closed

Replies have been disabled for this discussion.