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


Groups > comp.lang.python > #33045

RE: duck typing assert

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 <andriy.kornatskyy@live.com>
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 <andriy.kornatskyy@live.com>
To <ramit.prasad@jpmorgan.com>, "python-list@python.org" <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 <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 <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.3510.1352483770.27098.python-list@python.org> (permalink)
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

Show key headers only | View raw


duck(Foo).match(IFoo, <kwargs>)
duck(Foo).like(IFoo, <kwargs>)

Hm... function name in most cases is read as verb... this may cause confusion:
duck => synonyms => immerse, dip

Thanks.

Andriy Kornatskyy

----------------------------------------
> From: ramit.prasad@jpmorgan.com
> To: andriy.kornatskyy@live.com; python-list@python.org
> Subject: RE: duck typing assert
> Date: Fri, 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`, 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 | 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