Re: Trying to generate a list of the subclasses of C

2006-01-18 Thread Charles Krug
On 2006-01-16, Alex Martelli <[EMAIL PROTECTED]> wrote: > Charles Krug <[EMAIL PROTECTED]> wrote: >... >> I'm trying to create a list of all of C's subclasses: > > There's a class method for that very purpose: > class C(object): pass > ... class D(C): pass > ... class E(C): pas

Re: Trying to generate a list of the subclasses of C

2006-01-16 Thread Duncan Booth
Charles Krug wrote: > The end result I'm after is an automatically generated dictionary > containing instaces of the subclasses keyed by the subclass names: > > {'D':D(), 'E':E(), . . . } > > I can see the information I need in the module's __dict__ and by using > the dir() method, but I'm not h

Re: Trying to generate a list of the subclasses of C

2006-01-16 Thread Alex Martelli
Charles Krug <[EMAIL PROTECTED]> wrote: ... > I'm trying to create a list of all of C's subclasses: There's a class method for that very purpose: >>> class C(object): pass ... >>> class D(C): pass ... >>> class E(C): pass ... >>> C.__subclasses__() [, ] >>> Alex -- http://mail.python.or

Re: Trying to generate a list of the subclasses of C

2006-01-16 Thread Pierre Barbier de Reuille
Charles Krug a écrit : > List: > > I have this: > > # classC.py > > class C(object): pass > > class D(C): pass > > class E(C): pass > > def CSubclasses(): > for name in dir(): pass > > I'm trying to create a list of all of C's subclasses: > > import classC > > print C > aList = [] > fo

Re: Trying to generate a list of the subclasses of C

2006-01-16 Thread Diez B. Roggisch
> The end result I'm after is an automatically generated dictionary > containing instaces of the subclasses keyed by the subclass names: > > {'D':D(), 'E':E(), . . . } > > I can see the information I need in the module's __dict__ and by using > the dir() method, but I'm not having much success ex

Trying to generate a list of the subclasses of C

2006-01-16 Thread Charles Krug
List: I have this: # classC.py class C(object): pass class D(C): pass class E(C): pass def CSubclasses(): for name in dir(): pass I'm trying to create a list of all of C's subclasses: import classC print C aList = [] for name in dir(classC): print name, try: if issubcla