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


Groups > comp.lang.python > #53205

Re: Interface and duck typing woes

Path csiph.com!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder4.news.weretis.net!rt.uk.eu.org!newsfeed.xs4all.nl!newsfeed3.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <cameron@cskk.homeip.net>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.006
X-Spam-Evidence '*H*': 0.99; '*S*': 0.00; 'static': 0.04; 'nested': 0.07; '#define': 0.09; 'logic': 0.09; 'runtime': 0.09; 'wrong,': 0.09; 'python': 0.11; 'bug': 0.12; 'chasing': 0.16; 'from:addr:cs': 0.16; 'from:addr:zip.com.au': 0.16; 'from:name:cameron simpson': 0.16; 'macros': 0.16; 'message- id:@cskk.homeip.net': 0.16; 'raised.': 0.16; 'received:211.29': 0.16; 'received:211.29.132': 0.16; 'received:cskk.homeip.net': 0.16; 'received:homeip.net': 0.16; 'received:optusnet.com.au': 0.16; 'received:syd.optusnet.com.au': 0.16; 'reedy': 0.16; 'simpson': 0.16; 'exception': 0.16; 'flexibility': 0.16; 'prevent': 0.16; 'wrote:': 0.18; 'all,': 0.19; 'trying': 0.19; 'drawing': 0.19; 'thu,': 0.19; 'not,': 0.20; 'programming': 0.22; 'aug': 0.22; 'coding': 0.22; 'header:User-Agent:1': 0.23; 'error': 0.23; 'config': 0.24; 'java': 0.24; 'cheers,': 0.24; "haven't": 0.24; 'certain': 0.27; 'header:In-Reply-To:1': 0.27; 'point': 0.28; 'function': 0.29; 'testing': 0.29; 'chris': 0.29; 'am,': 0.29; 'errors': 0.30; "i'm": 0.30; 'code': 0.31; 'getting': 0.31; 'that.': 0.31; 'bunch': 0.31; 'probably': 0.32; 'front': 0.32; 'stuff': 0.32; 'option': 0.32; 'alone': 0.33; 'bugs': 0.33; 'checking': 0.33; 'mac': 0.33; "i'd": 0.34; 'problem': 0.35; 'but': 0.35; 'there': 0.35; 'received:com.au': 0.36; 'surely': 0.36; 'charset:us-ascii': 0.36; 'should': 0.36; 'wrong': 0.37; 'so,': 0.37; 'being': 0.38; 'sometimes': 0.38; 'received:211': 0.38; 'needed': 0.38; 'to:addr:python-list': 0.38; 'rather': 0.38; 'to:addr:python.org': 0.39; 'users': 0.40; 'catch': 0.60; 'event.': 0.60; 'worry': 0.60; 'course': 0.61; 'simple': 0.61; 'first': 0.61; 'content-disposition:inline': 0.62; "you'll": 0.62; 'making': 0.63; 'show': 0.63; 'protection': 0.63; 'great': 0.65; 'road': 0.65; 'believe': 0.68; 'frustrated': 0.68; 'price': 0.69; 'deeply': 0.69; 'therefore': 0.72; 'protect': 0.79; 'forth': 0.81; 'front.': 0.84; 'trouble.': 0.91; 'acknowledge': 0.93; '2013': 0.98
Date Thu, 29 Aug 2013 11:20:20 +1000
From Cameron Simpson <cs@zip.com.au>
To python-list@python.org
Subject Re: Interface and duck typing woes
MIME-Version 1.0
Content-Type text/plain; charset=us-ascii
Content-Disposition inline
In-Reply-To <CAPTjJmrVkYJrauULk5zOd1C_7ztQ4CPYLPNYgE+9+Hh4uPNZ2Q@mail.gmail.com>
User-Agent Mutt/1.5.21 (2010-09-15)
References <CAPTjJmrVkYJrauULk5zOd1C_7ztQ4CPYLPNYgE+9+Hh4uPNZ2Q@mail.gmail.com>
X-Optus-CM-Score 0
X-Optus-CM-Analysis v=2.1 cv=bpB1Wiqi c=1 sm=1 tr=0 a=YuQlxtEQCowy2cfE5kc7TA==:117 a=YuQlxtEQCowy2cfE5kc7TA==:17 a=ZtCCktOnAAAA:8 a=PO7r1zJSAAAA:8 a=LcaDllckn3IA:10 a=fTaCCuX0XY0A:10 a=kj9zAlcOel0A:10 a=vrnE16BAAAAA:8 a=8AHkEIZyAAAA:8 a=oBAijZZNKP4A:10 a=pGLkceISAAAA:8 a=XIpRDGagkoU-eVmaZTcA:9 a=CjuIK1q_8ugA:10 a=MSl-tDqOz04A:10
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.339.1377739246.19984.python-list@python.org> (permalink)
Lines 46
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1377739246 news.xs4all.nl 15874 [2001:888:2000:d::a6]:47351
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:53205

Show key headers only | View raw


On 29Aug2013 09:17, Chris Angelico <rosuav@gmail.com> wrote:
| On Thu, Aug 29, 2013 at 7:54 AM, Terry Reedy <tjreedy@udel.edu> wrote:
| > Depending on who the users will be, I might just not worry about it until an
| > exception is raised. If you try to protect against everything that you might
| > do wrong, you are on the road to madness, as the protection code might also
| > be buggy. (Too much testing has the same problem ;-).
| 
| I'd go further.
| 
| Do you believe that you can write code to catch every bug you might
| make? If so, you are naive and probably haven't spent much time
| programming yet :) And if not, then you must acknowledge that bugs
| WILL happen; therefore you will need to cope with them after the
| event. So rather than trying to prevent them all, just improve your
| means of coping, and you'll accomplish the same end with much less
| trouble.

I'm not so extreme. Yes, of course certain things will only show
at runtime and you should be prepared to have to deal with that.

However, when working in Java its type strictness caught a great
many simple brainfart logic errors by checking function signatures;
typically calling the wrong function/method or mangling arguments.
Getting this stuff up front was handy. Of course there's a price
there in terms of flexibility and all that wordy stuff defining the
functions in the first place. As an aside, you can also get a lot
of this checking in C with aggressive linting and making a bunch
of macros like:

  #define CNULL ((char *)NULL)
  #define CPNULL ((char **)NULL)

and so forth as needed - lint can then catch a lot of otherwise
unchecked comparisons.

Anyway, I digress. My point is that there are plusses to having
signature/type checking at coding time. It is not the Python Way,
but I surely cannot be alone in sometimes being frustrated chasing
a deeply nested runtime error that static type checking might have
found up front.

Cheers,
-- 
Cameron Simpson <cs@zip.com.au>

"waste cycles drawing trendy 3D junk"   - Mac Eudora v3 config option

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


Thread

Re: Interface and duck typing woes Cameron Simpson <cs@zip.com.au> - 2013-08-29 11:20 +1000
  Re: Interface and duck typing woes Roy Smith <roy@panix.com> - 2013-08-28 21:27 -0400

csiph-web