Liskov substitution principle (was: list(), tuple() should not place at "Built-in functions" in documentation)

Chris Angelico rosuav at gmail.com
Fri Jul 15 20:17:48 EDT 2011


On Sat, Jul 16, 2011 at 10:04 AM, Ben Finney <ben+python at benfinney.id.au> wrote:
>        def study(self, subject):
>            raise NotImplementedError
>
> See? We can have overstretched analogies *and* remain within the Liskov
> substitution principle.
>

Hehe! Of course I was speaking utterly in jest, but this raises
(sorry, never could resist a bad pun) another question: What if the
base class implemented study(), and then LazyStudent subclasses
Student but makes study() raise NotImpl? Would that break things? In a
sense, it breaks the whole "this is a student so it should act like a
student" rule. Suppose it raised UtterApathyError instead - does that
break the LSP?

Chris A
PS. The world's first horseless signature... trapped in the air!



More information about the Python-list mailing list