Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.mixmin.net!newsfeed.tele2net.at!newsfeed.utanet.at!feeder1.cambriumusenet.nl!82.197.223.108.MISMATCH!feeder2.cambriumusenet.nl!feeder3.cambriumusenet.nl!feed.tweaknews.nl!194.109.133.81.MISMATCH!newsfeed.xs4all.nl!newsfeed2.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.003 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; '*is*': 0.09; '[0]': 0.09; 'cc:addr:python-list': 0.11; 'jan': 0.12; "wouldn't": 0.14; 'keys.': 0.16; 'missing?': 0.16; 'non-string': 0.16; 'subject:subclasses': 0.16; 'substitution': 0.16; 'subtype': 0.16; 'to:addr:pearwood.info': 0.16; 'to:addr:steve+comp.lang.python': 0.16; "to:name:steven d'aprano": 0.16; 'sender:addr:gmail.com': 0.17; 'wrote:': 0.18; 'saying': 0.22; 'cc:addr:python.org': 0.22; '\xa0if': 0.24; 'cc:2**0': 0.24; 'daniel': 0.26; 'task': 0.26; 'header:In-Reply-To:1': 0.27; 'properties': 0.29; 'message- id:@mail.gmail.com': 0.30; 'url:wiki': 0.31; "d'aprano": 0.31; 'steven': 0.31; 'url:wikipedia': 0.31; 'violation': 0.31; 'etc.)': 0.35; 'objects': 0.35; 'but': 0.35; 'received:google.com': 0.35; '14,': 0.36; "he's": 0.36; 'url:org': 0.36; '(i.e.,': 0.38; 'desirable': 0.38; 'pm,': 0.38; 'according': 0.40; 'skip:* 10': 0.61; 'more': 0.64 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:date:message-id:subject :from:to:cc:content-type; bh=YWGl3Vs5Fg76vo5lCy6mjCmRebGAmd3405mQ5HVQ7TA=; b=fmg3vtYvBV3IQcRDgNSzTO03ps2lubDZRAq2I4YWh79WiKZCKDgad9koCVZqGsk4Ez W98Yr6vtU00sUh2zZ92YCe/VgaCGVOc+AGoMCDu5yOrIs5+hcu3gZVgmDSQiLSM+mIMP /X0fW6/WCm9hYBnbaKZJlN3kjykQGagTqI5kH/Alu2GhV6JQmGZ+Xlr44n2HMxcCFLYp GH3ciat7yTnXvKLEnrThxcYb6Cj+zQRW3GV3AhA5ohWrFR19gP+carIlQ8fFD4gz9Ax3 AmXp0uAOlMprmcbBtVDnNsRot6WQDq8QKGhCejCtDWu5zNIf8AKkyFWV+5UQ8wJS7pyx jYPw== MIME-Version: 1.0 X-Received: by 10.194.77.7 with SMTP id o7mr5306033wjw.35.1389833453409; Wed, 15 Jan 2014 16:50:53 -0800 (PST) Sender: meltingwax@gmail.com In-Reply-To: <52d5e408$0$29970$c3e8da3$5496439d@news.astraweb.com> References: <52d5e408$0$29970$c3e8da3$5496439d@news.astraweb.com> Date: Wed, 15 Jan 2014 19:50:53 -0500 X-Google-Sender-Auth: 271PuDvDw06E8AbqMhGY5jzBeJU Subject: Re: Chanelling Guido - dict subclasses From: Daniel da Silva To: "Steven D'Aprano" Content-Type: multipart/alternative; boundary=047d7bfd05fc499b6504f00bd1f1 X-Mailman-Approved-At: Thu, 16 Jan 2014 03:50:12 +0100 Cc: Python X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 73 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1389840613 news.xs4all.nl 2925 [2001:888:2000:d::a6]:35473 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:64041 --047d7bfd05fc499b6504f00bd1f1 Content-Type: text/plain; charset=ISO-8859-1 On Tue, Jan 14, 2014 at 8:27 PM, Steven D'Aprano < steve+comp.lang.python@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 of T, then > objects of type 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] Since S (TextOnlyDict) is more restrictive, it cannot be replaced for T (dict) because the program may be using non-string keys. Daniel --047d7bfd05fc499b6504f00bd1f1 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable


On Tue, Jan 14, 2014 at 8:27 PM, Steven D'Aprano = <steve+comp.lang.python@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?<= br>

Just to be pedantic, this is a v= iolation of the Liskov Substution Principle. According to Wikipedia, the pr= inciple states:

=A0if S is a=A0subtype=A0of T, then objects of=A0type=A0T may be rep= laced with objects of type S (i.e., objects of type S may be=A0substituted=A0for objects of type T) withou= t altering any of the desirable properties of that program (correctness, ta= sk performed, etc.) [0]

=A0Since S (TextOnlyDict) is more restrictive, it cannot be rep= laced for T (dict) because the program may be using non-string keys.
<= div>

Daniel
--047d7bfd05fc499b6504f00bd1f1--