Path: csiph.com!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!newsfeed.xs4all.nl!newsfeed5.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.004 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'arguments': 0.07; 'completeness': 0.07; 'check.': 0.09; 'received:155': 0.09; 'sentence': 0.09; 'ignore': 0.13; 'language': 0.14; '__len__,': 0.16; 'disclaimers': 0.16; 'disclaimers,': 0.16; 'foo;': 0.16; 'from:addr:jpmorgan.com': 0.16; 'readable': 0.16; 'received:155.180': 0.16; 'received:155.180.234': 0.16; 'received:159.53': 0.16; 'received:bankone.net': 0.16; 'received:exchad.jpmchase.net': 0.16; 'received:jpmchase.com': 0.16; 'received:jpmchase.net': 0.16; 'received:svr.bankone.net': 0.16; 'securities,': 0.16; 'sense,': 0.16; 'url:disclosures': 0.16; 'url:jpmorgan': 0.16; 'wording': 0.16; 'wrote:': 0.17; 'to:name:python-list@python.org': 0.20; 'java': 0.21; 'precise': 0.22; 'programming': 0.23; 'to:2**1': 0.23; 'received:169.254': 0.24; 'header:In-Reply-To:1': 0.25; 'looks': 0.26; 'url:wiki': 0.26; 'language.': 0.27; 'accuracy': 0.27; 'reflect': 0.27; 'url:wikipedia': 0.29; 'received:169': 0.29; 'words': 0.29; 'probably': 0.29; 'function': 0.30; 'sense': 0.31; 'point': 0.31; 'to:addr:python-list': 0.33; 'skip:d 20': 0.34; 'false': 0.35; 'replaced': 0.35; 'there': 0.35; 'but': 0.36; 'url:org': 0.36; 'limitation': 0.36; 'test': 0.36; 'thank': 0.36; 'passed': 0.37; 'subject:: ': 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; '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; 'received:169.254.8': 0.84; 'say:': 0.84; 'to:addr:live.com': 0.84 X-DKIM: OpenDKIM Filter v2.1.3 sz4.jpmchase.com qA9HbhrB028112 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=jpmorgan.com; s=smtpout; t=1352482663; bh=4f0EAbbOS05Bx2+fZ59sTPDSBD03qkqaZrjSXOD+z94=; h=From:To:Subject:Date:Message-ID:References:In-Reply-To: Content-Transfer-Encoding:MIME-Version:Content-Type; b=nF8b2ae6UajRHEAiikAhd/WlrlpNw0DqYjhZ7rQopqG+lsoWcxzOmC5Dors7ymfMZ ENa8EcMpI+Xc2xQweDUR5Q0RJhMDSXxFVFpNmjImpjKxe6ADDSqeAk5ujmsNValZkN XtrkzfkD9l+eyfu6cyyRpLAjvVPxi6szzPOvIFZQ= From: "Prasad, Ramit" To: Andriy Kornatskyy , "python-list@python.org" Subject: RE: duck typing assert Thread-Topic: duck typing assert Thread-Index: AQHNvglkFIDQFeTGJkmEObVb7xMqfpfhAxoAgABXsICAAEZZAIAAIu8A Date: Fri, 9 Nov 2012 17:37:29 +0000 References: , <509c412d$0$29980$c3e8da3$5496439d@news.astraweb.com>, , In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.67.79.47] Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-DLP-FWD: Yes Content-Type: text/plain; charset="iso-8859-1" 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: 31 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1352482672 news.xs4all.nl 6906 [2001:888:2000:d::a6]:60527 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:33041 Andriy Kornatskyy wrote:=0D=0A> =0D=0A> Thank you for all comments=2E=0D=0A= > =0D=0A> > It=A0makes very good sense to say:=0D=0A> >=0D=0A> > duckmatch(= IFoo)=2Ecompare(Foo)=0D=0A> =0D=0A> Since we do duck match of IFoo=2E=2E=2E= but there is no `duck match`, there is `duck test`=2E=A0I believe instead = of=0D=0A> `compare` is more readable with `equals`=2E Than it is more from= =A0mathematics - precise answer=2E=2E=2E=A0that you can not=0D=0A> guarante= e at all in dynamic programming language=2E So it false to use such wording= to reflect this check=2E We can=0D=0A> only make an assumption that one lo= oks like the other (similar)=2E=2E=2E with some limitation of cause=2E=2E= =2E=0D=0A> understanding what is `duck test`=2E=0D=0A> =0D=0A> http://en=2E= wikipedia=2Eorg/wiki/Duck_test=0D=0A> =0D=0A> The intent is to make such la= nguage `construct` so it reads as English sentence that make sense, and not= =0D=0A> mandatory `pythonic` way (readability counts, java smokes aside)=2E= =0D=0A> =0D=0A> is_similar(Foo)=2Eto(IFoo) # <=3D but we lost `duck test` s= ense here?=0D=0A> =0D=0A> Words `looks` and `like` are coming from duck tes= t and point also direction:=0D=0A> =0D=0A> # 1=0D=0A> looks(Foo)=2Elike(IFo= o, notice=3D['__len__'], ignore_funcs=3D['foo'], ignore_argspec['bar'])=0D= =0A> =0D=0A> English sentence equivalent: if functions in Foo looks like on= e in IFoo than, probably, IFoo can be replaced=0D=0A> with Foo; notice to c= heck __len__, it is safe to ignore function `foo` and arguments passed to `= bar`=2E=0D=0A> =0D=0A> # 2=0D=0A> looks(Foo, notice=3D['__len__'], ignore_f= uncs=3D['foo'], ignore_argspec['bar'])=2Elike(IFoo)=0D=0A> =0D=0A> English = sentence equivalent:=A0while looking at Foo notice to check `__len__`, it i= s safe to ignore function `foo`=0D=0A> and=A0arguments passed to `bar`, tha= n probably it like IFoo=2E=0D=0A=0D=0AWhat about?=0D=0A=0D=0Aduck(Foo)=2Eeq= uivalent_to(IFoo, ) =0D=0Aduck(Foo)=2Ematches(IFoo, )=0D=0A= =0D=0AThis email is confidential and subject to important disclaimers and= =0D=0Aconditions including on offers for the purchase or sale of=0D=0Asecur= ities, accuracy and completeness of information, viruses,=0D=0Aconfidential= ity, legal privilege, and legal entity disclaimers,=0D=0Aavailable at http:= //www=2Ejpmorgan=2Ecom/pages/disclosures/email=2E