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


Groups > comp.lang.python > #33028

RE: duck typing assert

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 <andriy.kornatskyy@live.com>
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 <andriy.kornatskyy@live.com>
To <rosuav@gmail.com>, "python-list@python.org" <python-list@python.org>
Subject RE: duck typing assert
Date Fri, 9 Nov 2012 17:37:11 +0300
Importance Normal
In-Reply-To <CAPTjJmq4-+XcQ9NO6L9BjEjEw0D_=cs60g1ONa+_YZOvmRA8hQ@mail.gmail.com>
References <CAPTjJmq4-+XcQ9NO6L9BjEjEw0D_=cs60g1ONa+_YZOvmRA8hQ@mail.gmail.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 <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.3497.1352471898.27098.python-list@python.org> (permalink)
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

Show key headers only | View raw


There is sense for #2. Let me explain. There is basic IFoo implementation and improved Foo. While I switched to Foo, I still want to be as close to IFoo as possible, since there might be sense to switch to Foo2 later, which conform to IFoo.

Here is the problem: if I will not assert #2 potentially I will use some `features` that are not in IFoo, thus that breaks my code switching to Foo2 later.

That might not apply for 100% usability cases, just wanted to point that out as reasonable thing.

Thanks.

Andriy Kornatskyy


----------------------------------------
> Date: Sat, 10 Nov 2012 01:15:36 +1100
> Subject: Re: duck typing assert
> From: rosuav@gmail.com
> To: python-list@python.org
>
> On Sat, Nov 10, 2012 at 1:01 AM, Andriy Kornatskyy
> <andriy.kornatskyy@live.com> wrote:
> >
> > 1. In looks-like we check features of Foo (that may be superset) of what 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, but since there's no difference between a
> "class" and an "interface", 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, as in
> Steven's example, it's fine to have an actor who can sing when you
> don't need her to. When you post job openings, 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
 		 	   		  

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