Possibly a stupid question regarding Python Classes

Adonis deltapigz at telocity.com
Sun Nov 17 11:18:29 EST 2002


Is this even possible:

class Foo:
    def Bar(self):
        print 'Foo'

class Fib(Foo):
    def Bar(self):
        # do the original Foo.Bar()
        # NOTE: w/o needing to instantiate Foo
        # then do:
        print 'Bar'

So in essence I want to override the Bar function, but as well do what it
would if it were instantiated. I know I could instantiate Foo prior to
printing Bar, but was wondering if there was a way to keep it within the
same process.

Any help is greatly appreciated.

Adonis





More information about the Python-list mailing list