Why not allow empty code blocks?

Chris Angelico rosuav at gmail.com
Sun Jul 24 23:12:02 EDT 2016


On Mon, Jul 25, 2016 at 12:48 PM, Michael Torrie <torriem at gmail.com> wrote:
> Far more often I'm bitten by the dynamic nature of Python (would happen
> in any dynamic language).  I'll be using a particular member attribute
> which I accidentally misspell somewhere and sometimes that results in
> silent failure.  Something doesn't work, but no exception is thrown.
> Unit tests, and perhaps lint, are required to catch these errors.  That
> is one thing about a dynamic language: comprehensive testing is required
> as you go along.
>

To be quite honest, comprehensive testing is needed in more static
languages too. There are certain categories of error which can be
detected by a compiler/linter, and certain which cannot; a language
that forces you to declare variables will catch variable name
misspellings, but only if they don't land you on an existing variable,
and still won't catch the dynamic places like dict keys (imagine
getting a block of JSON from somewhere, converting it into a
dictionary, and looking up stuff in it - the compiler can't know
whether your incoming data is correct and your code wrong, or the
other way around). A language with less dynamism might be able to
catch more, but still not everything, so ultimately, it all comes down
to testing anyway.

ChrisA



More information about the Python-list mailing list