Alan Gauld said unto the world upon 2005-04-23 15:18:
I am wondering about the Pythonic way to handle the problem of
ostriches, emus, and penguins. (I cannot recall from where I got the
example.)


Its not really a Python issue its one of several similar conundrums in
OOP in any language.


Thanks Alan, Kent, and Rich for the replies.

Since posting I retraced my steps and found where I came across the example: an OK book Object-Oriented Thought Process, The, Second Edition By Matt Weisfeld that I read on safari <http://safari.oreilly.com/0672326116/copyrightpg>. Weisfled points out the ostrich problem has often been cited by those who say "don't inherit, compose".

Alan's second solution (the mixin approach), seems to go in that direction. (I'm not attributing endorsement of "don't inherit" to any of the respondents!) In spirit, if not details, Rich's Strategy Pattern suggestion seems to point in that direction, too.

Any of these solutions (or the alternatives in my original post) seem likely to be messy in some contexts. I take Kent and Alan's points to that effect.


I do remain a bit surprised that there seems to be no way to implement what I naively thought would be the obvious solution -- to remove an inherited method from the instance's dictionary.


Anyway, thanks again to all,

Brian vdB

_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to