Python supports LSP, does it?

Mike Meyer mwm at mired.org
Tue Aug 9 22:11:22 EDT 2005


Andy Leszczynski <leszczynscyATnospam.yahoo.com.nospam> writes:
> 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?

It's not a true statement. Nothing in the language enforces LSP. In
fact, there's not even a when a function/method is invoked to make
sure the type passed in is a subtype of the type you expect; there's
currently no way to even declare what that type is.

What it does have is duck typing. You can pass any object to any
function/method, and it will work so long as it has the right set of
features and attributes.

The wikipedia was really abusing the phrase LSP. I've corrected the
wikipedia.

     <mike
-- 
Mike Meyer <mwm at mired.org>			http://www.mired.org/home/mwm/
Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information.



More information about the Python-list mailing list