HOWTO restrict multiply inherited class to on sub-class

Luke Kenneth Casson Leighton lkcl at angua.rince.de
Mon Apr 2 11:31:27 EDT 2001


On Mon, Apr 02, 2001 at 04:18:46PM +0100, Michael Hudson wrote:

> > x = new Inherited();
> > 
> > y = (Base1*)x;
> >     ^^^^^^^
> > 
> > how do you do _this_ in python?
> 
> Don't.  What does it buy you?

data hiding.

> Python doesn't really do data hiding.
 
ahh... :)

> > i.e. i have a Database-access class that inherits from about
> > six separate sub-database classes.
> > 
> > i want another class to have access to only ONE of the subsets
> > of functionality.
> 
> Why?

there are scores of database functions available: i don't want
one object to have access to any more database functions than
it strictly needs.

[example code / explanation cut]

> I hope you reconsider your need to do this, but if you don't, HTH.

python is very simple and clear.

to add obscurity for the sake of a language limitation is not,
imo, worth the hassle.

thanks for the feedback.

luke




More information about the Python-list mailing list