Differences creating tuples and collections.namedtuples

Chris Angelico rosuav at gmail.com
Wed Feb 20 07:50:25 CET 2013

On Wed, Feb 20, 2013 at 2:38 PM, Terry Reedy <tjreedy at udel.edu> wrote:
> Liskov Substitution Principle (LSP): I met this over 15 years ago reading
> debates among OOP enthusiasts about whether Rectangle should be a subclass
> of Square or Square a subclass of Rectangle, and similarly, whether Ostrich
> can be a legitimate subclass of Bird.
> The problem I see with the LSP for modeling either abstract or concrete
> entities is that we in fact do define subclasses by subtraction or
> limitation, as well as by augmentation, while the LSP only allows the
> latter.

A plausible compromise is to demand LSP in terms of programming, but
not necessarily functionality. So an Ostrich would have a fly() method
that returns some kind of failure, in the same way that any instance
of any flying-bird could have injury or exhaustion that prevents it
from flying. It still makes sense to attempt to fly - an ostrich IS a
bird - but it just won't succeed.


More information about the Python-list mailing list