Possibly a stupid question regarding Python Classes
Gonçalo Rodrigues
op73418 at mail.telepac.pt
Sun Nov 17 17:45:56 EST 2002
On Sun, 17 Nov 2002 11:18:29 -0500, "Adonis" <deltapigz at telocity.com>
wrote:
>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
>
In the 2.2 new-style class world you can use
super(Fib, self).Bar()
To call your super class's implementation of the Bar method.
HTH,
Gonçalo Rodrigues
More information about the Python-list
mailing list