Re: Getting a list of all classes derived from a base class

2006-04-03 Thread Alex Martelli
Vijairaj <[EMAIL PROTECTED]> wrote: > Thanks Dylan and Alex, that was a new learning for me. > > but both the solutions don't work in jython 2.1 is there an alternative > that will work with jython2.1 Alas, no: your simple idea is essentially the best you can do in any implementation of Pyhon at

Re: Getting a list of all classes derived from a base class

2006-04-03 Thread Alex Martelli
Dylan Moreland <[EMAIL PROTECTED]> wrote: ... > > do not use old-style classes: they exist ONLY for backwards > > compatibility. ... > > and you can call Test.__subclasses__() to get a list of all extant > > subclassed of Test at any time. ... > Thanks Alex. That's a new one to me -- new-s

Re: Getting a list of all classes derived from a base class

2006-04-03 Thread Dylan Moreland
Alex Martelli wrote: > Vijairaj R <[EMAIL PROTECTED]> wrote: >... > > class Test: > > do not use old-style classes: they exist ONLY for backwards > compatibility. > > Make you class Test new-style: > > class Test(object): >... > > > and you can call Test.__subclasses__() to get a list of a

Re: Getting a list of all classes derived from a base class

2006-04-03 Thread Vijairaj
Thanks Dylan and Alex, that was a new learning for me. but both the solutions don't work in jython 2.1 is there an alternative that will work with jython2.1 -- Thanks, Vijairaj -- http://mail.python.org/mailman/listinfo/python-list

Re: Getting a list of all classes derived from a base class

2006-04-02 Thread Alex Martelli
Vijairaj R <[EMAIL PROTECTED]> wrote: ... > class Test: do not use old-style classes: they exist ONLY for backwards compatibility. Make you class Test new-style: class Test(object): ... and you can call Test.__subclasses__() to get a list of all extant subclassed of Test at any time.

Getting a list of all classes derived from a base class

2006-04-02 Thread Vijairaj R
Hi, I have a requirement to findout all the classes that are derived from a single base class. This is how I do it currently. class Test: case = [] class Test1(Test): Test.case.append("Test1") class Test2(Test): Test.case.append("Test2") 1. Is there a better way of doing this. 2. I

Re: Getting a list of all classes derived from a base class

2006-04-02 Thread Dylan Moreland
Vijairaj R wrote: > Hi, > I have a requirement to findout all the classes that are derived from a > single base class. > > This is how I do it currently. > > class Test: > case = [] > > class Test1(Test): > Test.case.append("Test1") > > class Test2(Test): > Test.case.append("Test2") >