[Tutor] Hiding Superclass Methods
knacktus at googlemail.com
Mon Oct 11 08:25:24 CEST 2010
Am 11.10.2010 06:24, schrieb Denis Gomes:
> Hi Everyone,
> I have a basic python question. I am writing an n dimensional vector
> class by inheriting from the builtin python list object. I want to be
> able to hide the parent object's methods in the derived class instances.
Why inheriting then?
Another approach to reusing exisiting methods is to wrap them into your
newly defined methods. Here you would not inherit from a list, but
create a list in your class (composition). E.g.
self.data = 
def append_data(self, new_data):
Actually I use this all the time. And I used this before I knew about
Inheritance makes sence, when you want to reuse (almost) all methods of
the superclass, like in GUI toolkits, where you typically have a base
widget as superclass of a all other widgets.
> I know I can overload the method in the derived class and raise some
> sort of an implementation error but that is not what I had in mind. I am
> also not looking to use numpy. This is strictly for learning purposes.
> Is there a way to hide superclass methods in python?
> Thanks to all,
> Tutor maillist - Tutor at python.org
> To unsubscribe or change subscription options:
More information about the Tutor