Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!eternal-september.org!feeder.eternal-september.org!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!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.009 X-Spam-Evidence: '*H*': 0.98; '*S*': 0.00; 'mathematics': 0.04; 'arguments': 0.07; 'completeness': 0.07; 'check.': 0.09; 'sentence': 0.09; 'ignore': 0.13; 'language': 0.14; 'cases': 0.15; '__len__,': 0.16; 'disclaimers': 0.16; 'disclaimers,': 0.16; 'email addr:jpmorgan.com': 0.16; 'foo;': 0.16; 'readable': 0.16; 'securities,': 0.16; 'sense,': 0.16; 'url:disclosures': 0.16; 'url:jpmorgan': 0.16; 'wording': 0.16; 'wrote:': 0.17; 'typing': 0.17; '+0000': 0.20; 'to:name:python-list@python.org': 0.20; 'skip:- 40': 0.21; 'thanks.': 0.21; 'java': 0.21; 'precise': 0.22; 'programming': 0.23; 'to:2**1': 0.23; 'header:In-Reply-To:1': 0.25; 'looks': 0.26; 'url:wiki': 0.26; 'language.': 0.27; 'accuracy': 0.27; 'reflect': 0.27; 'assert': 0.29; 'url:wikipedia': 0.29; 'date:': 0.29; 'words': 0.29; 'probably': 0.29; 'fri,': 0.30; 'function': 0.30; 'sense': 0.31; 'point': 0.31; 'from:addr:live.com': 0.33; 'to:addr:python-list': 0.33; 'skip:d 20': 0.34; 'false': 0.35; 'nov': 0.35; 'replaced': 0.35; 'there': 0.35; 'subject:': 0.36; 'but': 0.36; 'url:org': 0.36; 'limitation': 0.36; 'email addr:python.org': 0.36; 'test': 0.36; 'thank': 0.36; 'passed': 0.37; 'subject:: ': 0.38; 'from:': 0.38; 'skip:l 20': 0.38; 'some': 0.38; 'url:en': 0.38; 'instead': 0.39; 'to:addr:python.org': 0.39; 'notice': 0.39; 'skip:u 10': 0.60; 'most': 0.61; 'email name:python-list': 0.62; 'safe': 0.63; 'skip:n 10': 0.63; 'information,': 0.63; 'url:email': 0.63; 'more': 0.63; 'legal': 0.65; 'subject': 0.66; 'purchase': 0.67; 'believe': 0.69; 'sale': 0.76; 'about?': 0.84; 'probably,': 0.84; 'say:': 0.84; 'charset:windows-1251': 0.97 X-Originating-IP: [213.130.16.2] From: Andriy Kornatskyy To: , "python-list@python.org" Subject: RE: duck typing assert Date: Fri, 9 Nov 2012 20:55:03 +0300 Importance: Normal In-Reply-To: <5B80DD153D7D744689F57F4FB69AF4741678CE1A@SCACMX008.exchad.jpmchase.net> References: , , <509c412d$0$29980$c3e8da3$5496439d@news.astraweb.com>, , , , , , <5B80DD153D7D744689F57F4FB69AF4741678CE1A@SCACMX008.exchad.jpmchase.net> Content-Type: text/plain; charset="windows-1251" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginalArrivalTime: 09 Nov 2012 17:55:03.0345 (UTC) FILETIME=[58449A10:01CDBEA3] 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: 75 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1352483770 news.xs4all.nl 6980 [2001:888:2000:d::a6]:46708 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:33045 duck(Foo).match(IFoo=2C ) duck(Foo).like(IFoo=2C ) Hm... function name in most cases is read as verb... this may cause confusi= on: duck =3D> synonyms =3D> immerse=2C dip Thanks. Andriy Kornatskyy ---------------------------------------- > From: ramit.prasad@jpmorgan.com > To: andriy.kornatskyy@live.com=3B python-list@python.org > Subject: RE: duck typing assert > Date: Fri=2C 9 Nov 2012 17:37:29 +0000 > > Andriy Kornatskyy wrote: > > > > Thank you for all comments. > > > > > It makes very good sense to say: > > > > > > duckmatch(IFoo).compare(Foo) > > > > Since we do duck match of IFoo... but there is no `duck match`=2C there= is `duck test`. I believe instead of > > `compare` is more readable with `equals`. Than it is more from mathemat= ics - precise answer... that you can not > > guarantee at all in dynamic programming language. So it false to use su= ch wording to reflect this check. We can > > only make an assumption that one looks like the other (similar)... with= some limitation of cause... > > understanding what is `duck test`. > > > > http://en.wikipedia.org/wiki/Duck_test > > > > The intent is to make such language `construct` so it reads as English = sentence that make sense=2C and not > > mandatory `pythonic` way (readability counts=2C java smokes aside). > > > > is_similar(Foo).to(IFoo) # <=3D but we lost `duck test` sense here? > > > > Words `looks` and `like` are coming from duck test and point also direc= tion: > > > > # 1 > > looks(Foo).like(IFoo=2C notice=3D['__len__']=2C ignore_funcs=3D['foo']= =2C ignore_argspec['bar']) > > > > English sentence equivalent: if functions in Foo looks like one in IFoo= than=2C probably=2C IFoo can be replaced > > with Foo=3B notice to check __len__=2C it is safe to ignore function `f= oo` and arguments passed to `bar`. > > > > # 2 > > looks(Foo=2C notice=3D['__len__']=2C ignore_funcs=3D['foo']=2C ignore_a= rgspec['bar']).like(IFoo) > > > > English sentence equivalent: while looking at Foo notice to check `__le= n__`=2C it is safe to ignore function `foo` > > and arguments passed to `bar`=2C than probably it like IFoo. > > What about? > > duck(Foo).equivalent_to(IFoo=2C ) > duck(Foo).matches(IFoo=2C ) > > This email is confidential and subject to important disclaimers and > conditions including on offers for the purchase or sale of > securities=2C accuracy and completeness of information=2C viruses=2C > confidentiality=2C legal privilege=2C and legal entity disclaimers=2C > available at http://www.jpmorgan.com/pages/disclosures/email. =