Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #33041

RE: duck typing assert

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 <ramit.prasad@jpmorgan.com>
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" <ramit.prasad@jpmorgan.com>
To Andriy Kornatskyy <andriy.kornatskyy@live.com>, "python-list@python.org" <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 <CAPTjJmq6xbnKm32p0KDjunDHo4bbaMKt5a5nsptj=HJmyKzyWg@mail.gmail.com> <DUB117-W1157407BDC6D06349AB7F5391680@phx.gbl>
In-Reply-To <DUB117-W1157407BDC6D06349AB7F5391680@phx.gbl>
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 <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.3506.1352482672.27098.python-list@python.org> (permalink)
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

Show key headers only | View raw


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`, there is `duck test`. I believe instead of
> `compare` is more readable with `equals`. Than it is more from mathematics - precise answer... that you can not
> guarantee at all in dynamic programming language. So it false to use such 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, and not
> mandatory `pythonic` way (readability counts, java smokes aside).
> 
> is_similar(Foo).to(IFoo) # <= but we lost `duck test` sense here?
> 
> Words `looks` and `like` are coming from duck test and point also direction:
> 
> # 1
> looks(Foo).like(IFoo, notice=['__len__'], ignore_funcs=['foo'], ignore_argspec['bar'])
> 
> English sentence equivalent: if functions in Foo looks like one in IFoo than, probably, IFoo can be replaced
> with Foo; notice to check __len__, it is safe to ignore function `foo` and arguments passed to `bar`.
> 
> # 2
> looks(Foo, notice=['__len__'], ignore_funcs=['foo'], ignore_argspec['bar']).like(IFoo)
> 
> English sentence equivalent: while looking at Foo notice to check `__len__`, it is safe to ignore function `foo`
> and arguments passed to `bar`, than probably it like IFoo.

What about?

duck(Foo).equivalent_to(IFoo, <kwargs>) 
duck(Foo).matches(IFoo, <kwargs>)

This email is confidential and subject to important disclaimers and
conditions including on offers for the purchase or sale of
securities, accuracy and completeness of information, viruses,
confidentiality, legal privilege, and legal entity disclaimers,
available at http://www.jpmorgan.com/pages/disclosures/email.  

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

duck typing assert‏ Andriy Kornatskyy <andriy.kornatskyy@live.com> - 2012-11-08 20:34 +0300
  Re: duck typing assert‏ Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-11-08 23:33 +0000
    Re: duck typing assert Ian Kelly <ian.g.kelly@gmail.com> - 2012-11-08 18:00 -0700
      Re: duck typing assert Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-11-09 13:36 +0000
        RE: duck typing assert Andriy Kornatskyy <andriy.kornatskyy@live.com> - 2012-11-09 17:01 +0300
        Re: duck typing assert Chris Angelico <rosuav@gmail.com> - 2012-11-10 01:15 +1100
        RE: duck typing assert Andriy Kornatskyy <andriy.kornatskyy@live.com> - 2012-11-09 17:37 +0300
    Re: duck typing assert Chris Angelico <rosuav@gmail.com> - 2012-11-09 17:14 +1100
    RE: duck typing assert Andriy Kornatskyy <andriy.kornatskyy@live.com> - 2012-11-09 13:26 +0300
    RE: duck typing assert "Prasad, Ramit" <ramit.prasad@jpmorgan.com> - 2012-11-09 17:37 +0000
    RE: duck typing assert Andriy Kornatskyy <andriy.kornatskyy@live.com> - 2012-11-09 20:55 +0300

csiph-web