On Tue, Jan 14, 2014 at 8:27 PM, Steven D'Aprano < steve+comp.lang.pyt...@pearwood.info> wrote: > > But reading Guido, I think he's saying that wouldn't be a good idea. I > don't get it -- it's not a violation of the Liskov Substitution > Principle, because it's more restrictive, not less. What am I missing? >
Just to be pedantic, this *is* a violation of the Liskov Substution Principle. According to Wikipedia, the principle states: if S is a subtype <http://en.wikipedia.org/wiki/Subtype> of T, then > objects of type <http://en.wikipedia.org/wiki/Datatype> T may be replaced > with objects of type S (i.e., objects of type S may be *substituted* for > objects of type T) without altering any of the desirable properties of that > program (correctness, task performed, etc.) > [0]<http://en.wikipedia.org/wiki/Liskov_substitution_principle> Since S (TextOnlyDict) is more restrictive, it cannot be replaced for T (dict) because the program may be using non-string keys. Daniel
-- https://mail.python.org/mailman/listinfo/python-list