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


Groups > comp.lang.python > #53208

Re: Interface and duck typing woes

From Roy Smith <roy@panix.com>
Newsgroups comp.lang.python
Subject Re: Interface and duck typing woes
Date 2013-08-28 21:27 -0400
Organization PANIX Public Access Internet and UNIX, NYC
Message-ID <roy-6705CC.21273428082013@news.panix.com> (permalink)
References <CAPTjJmrVkYJrauULk5zOd1C_7ztQ4CPYLPNYgE+9+Hh4uPNZ2Q@mail.gmail.com> <mailman.339.1377739246.19984.python-list@python.org>

Show all headers | View raw


In article <mailman.339.1377739246.19984.python-list@python.org>,
 Cameron Simpson <cs@zip.com.au> wrote:

> 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.

One time when I really do miss static typing (and often emulate by 
sprinkling isinstance() assertions into my functions) is when I do a big 
refactoring.

I'll change (to pick a real example) Song.get(id) from taking an integer 
to taking an ObjectId.  I'll hunt through my source code to find all the 
places where I call Song.get(), but usually I'll miss a few.  The 
assertions will help me catch that quickly because I'll get an easy to 
understand exception thrown right at the first point of contact, rather 
than something cryptic happening 12 stack frames down, deep in the 
database layer.

Back to comp.lang.python | Previous | NextPrevious 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