Python supports LSP, does it?

phil hunt zen19725 at zen.co.uk
Wed Aug 10 20:19:19 EDT 2005


On Tue, 09 Aug 2005 18:36:56 -0500, Andy Leszczynski <leszczynscyATnospam.yahoo.com.nospam> wrote:
>wikipedia 
>(http://en.wikipedia.org/wiki/Python_programming_language#Object-oriented_programming) 
>says:
>"""
>Python's support for object oriented programming paradigm is vast. It 
>supports polymorphism [...] fully in the Liskov substitution 
>principle-sense for all objects.
>"""
>
>Just wondering if it is true statement. Is not LSP more a quality of the 
>desing of class hierachy rather then language itslef? Comments?

According to Wikipedia, the Liskov substitution principle is:

  Let q(x) be a property provable about objects x of type T. Then 
  q(y) should be true for objects y of type S where S is a subtype of T

To me, this is nonsense. Under this definition any subtype must 
behave the same as its parent type, becausde if it doesn't there 
will be some q(y) that are different to q(x).

But if it behaves the same, what's the point of having a subtype?

Am I missing something?

-- 
Email: zen19725 at zen dot co dot uk





More information about the Python-list mailing list