All functions from self and inherited classes

Jonas Meyer Rasmussen meyer at kampsax.dtu.dk
Thu Jun 14 19:22:59 EDT 2001


Hey!

Maybe this will help you?

class a:
        def a( self ):
                print "a"
class b( a ):
        def b( self ):
                print "b"
class c( b ):
        def c( self ):
                print "c"
class d( c ):
        def d( self ):
                print "d"

class x( d ):
        def x( self ):
                print "x"
        def test( self ):
                clss = self.__class__
                bases = clss.__bases__
                print 'self:', clss.__name__, 'methods:', dir( clss )
                print 'inherited'
                while bases != ():
                        base, = bases
                        print 'class:',base.__name__, 'methods:', dir(
base )
                        bases = base.__bases__
test = x()
print "initiating test"
test.test()

It works fine here(2.0)...although if you are going to use multiple
inheritance there will probably
be some problems, because the touple bases will then not be ( base1, ) but
( base1, base2... )
and i dont know how to handle that ;)

McEinar





More information about the Python-list mailing list