Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder.erje.net!eu.feeder.erje.net!multikabel.net!newsfeed20.multikabel.net!news2.euro.net!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.047 X-Spam-Evidence: '*H*': 0.91; '*S*': 0.00; 'problem:': 0.07; 'suppose': 0.07; 'unrecognized': 0.07; 'python': 0.09; '"class"': 0.09; 'foo,': 0.09; 'sat,': 0.15; '(assuming': 0.16; '[1].': 0.16; 'foo.': 0.16; 'wrote:': 0.17; 'switched': 0.17; 'typing': 0.17; 'usability': 0.17; 'to:name:python-list@python.org': 0.20; 'skip:- 40': 0.21; 'thanks.': 0.21; 'to:2**1': 0.23; 'thus': 0.24; 'header :In-Reply-To:1': 0.25; '[1]': 0.27; 'am,': 0.27; 'checking': 0.27; 'possible,': 0.27; 'fine': 0.28; 'post': 0.28; 'assert': 0.29; 'date:': 0.29; 'url:mailman': 0.29; 'normally': 0.30; 'basic': 0.30; 'expect': 0.31; 'sense': 0.31; 'code': 0.31; 'point': 0.31; 'url:python': 0.32; 'generally': 0.32; 'switch': 0.32; "who's": 0.32; 'url:listinfo': 0.32; 'cases,': 0.33; 'from:addr:live.com': 0.33; 'problem': 0.33; 'to:addr:python-list': 0.33; 'that,': 0.34; 'minimum': 0.34; 'nov': 0.35; 'there': 0.35; 'subject:': 0.36; 'but': 0.36; 'wanted': 0.36; 'url:org': 0.36; 'email addr:python.org': 0.36; 'unable': 0.36; 'subject:: ': 0.38; 'from:': 0.38; 'skip:l 20': 0.38; 'some': 0.38; 'to:addr:python.org': 0.39; 'apply': 0.39; 'url:mail': 0.40; 'save': 0.61; "you'll": 0.62; '(that': 0.62; 'email name:python- list': 0.62; 'improved': 0.62; 'between': 0.63; 'close': 0.63; 'email addr:gmail.com': 0.63; 'here': 0.65; 'legal': 0.65; 'potentially': 0.66; '100%': 0.76; '+1100': 0.84; 'hassle.': 0.84; 'offers.': 0.84; 'only:': 0.84; 'openings,': 0.91; 'charset:windows-1251': 0.97 X-Originating-IP: [194.44.213.194] From: Andriy Kornatskyy To: , "python-list@python.org" Subject: RE: duck typing assert Date: Fri, 9 Nov 2012 17:37:11 +0300 Importance: Normal In-Reply-To: References: , <509c412d$0$29980$c3e8da3$5496439d@news.astraweb.com>, , <509d06e7$0$29980$c3e8da3$5496439d@news.astraweb.com>, , Content-Type: text/plain; charset="windows-1251" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginalArrivalTime: 09 Nov 2012 14:37:11.0275 (UTC) FILETIME=[B3F67BB0:01CDBE87] 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: 56 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1352471898 news.xs4all.nl 6919 [2001:888:2000:d::a6]:32855 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:33028 There is sense for #2. Let me explain. There is basic IFoo implementation a= nd improved Foo. While I switched to Foo=2C I still want to be as close to = IFoo as possible=2C since there might be sense to switch to Foo2 later=2C w= hich conform to IFoo. Here is the problem: if I will not assert #2 potentially I will use some `f= eatures` that are not in IFoo=2C thus that breaks my code switching to Foo2= later. That might not apply for 100% usability cases=2C just wanted to point that = out as reasonable thing. Thanks. Andriy Kornatskyy ---------------------------------------- > Date: Sat=2C 10 Nov 2012 01:15:36 +1100 > Subject: Re: duck typing assert > From: rosuav@gmail.com > To: python-list@python.org > > On Sat=2C Nov 10=2C 2012 at 1:01 AM=2C Andriy Kornatskyy > wrote: > > > > 1. In looks-like we check features of Foo (that may be superset) of wha= t IFoo offers. > > > > assert looks(Foo).like(IFoo) > > > > 2. We can check if Foo is limited to IFoo only: > > > > assert looks(IFoo).like(Foo) > > > > So it valid to have both asserts. > > You'll almost never need #2=2C but since there's no difference between a > "class" and an "interface"=2C it's perfectly legal to switch them > around. > > But I would generally expect that unrecognized methods are never a > problem (assuming they don't collide with anything) - that=2C as in > Steven's example=2C it's fine to have an actor who can sing when you > don't need her to. When you post job openings=2C you don't normally ask > for someone with "5+ years Python experience and unable to program in > REXX" [1]. You're checking for a minimum set of requirements. > > [1] Though I suppose you might ask for someone who's unable to program > in Pascal. Might save you some hassle. > > ChrisA > -- > http://mail.python.org/mailman/listinfo/python-list =