How coding in Python is bad for you

Brandon McCaig bamccaig at
Thu Jan 26 23:07:39 EST 2017

On Tue, Jan 24, 2017 at 07:31:18PM +0000, Ben Bacarisse wrote:
> The trouble is that I've been programming for so long that I
> can't remember what it's like to make block and/or indent
> errors.  Obviously I make typos but they don't survive more
> than a few seconds.

Agreed. In very rare circumstances (likely very tired) you might
make such a mistake without catching it, but typically you'll
catch it during testing, and code review is another chance to
catch it. Source control FTW. I think that a lot of these kinds
of problems happen to beginners and the beginners make the most
noise about how it will be a problem. I initially was against
Python's significant white-space, but in hindsight I can see how
it saves a bit of typing and is not necessarily any worse off.

Hell, considering the code that I have seen in the wild it might
even catch some extra errors that become syntax errors! It's not
at all rare for indentation to not match in languages that don't
require it to at least fit a pattern.

I think that an apples to apples comparison of an erroneous
indentation level would be comparing a misplaced brace:

    foo {

wapz. Was that supposed to be "foo { bar; baz; }" or "foo { bar;
 } baz;" ? That's effectively the same problem that you might
have with Python code. The answer? Hopefully it's obvious when
looking at the code! If it's not, hopefully source control can
tell you. And if you can't be certain, *talk* to somebody.
There's no substitute for communication.

> In Python the editor could, for example, highlight the block
> you are typing in, so as soon as you leave the body of the 'if'
> it would stop being marked and the containing code would be
> highlighted.  Just moving the cursor up and down would show you
> what block everything is in.  I don't know if any editors help
> like this -- that's part of my reason to ask.

That's actually a pretty neat idea. I don't think I've ever
encoutered an editor that does (or if I have, it has either been
too long or so subtle that it doesn't stand out). I think that it
is a pretty good idea though.

I certainly find it useful to highlight matching braces in
editors, but it can be a pain still. I think that highlighting
the entire block could be useful. Though I suppose it might be
too noisy and distract from what matters? Alternatively, you'd
need different levels of indentation to capture nested
indentation. That shouldn't be a problem if people are limiting
their indentation levels though...


Brandon McCaig <bamccaig at> <bambams at>
Castopulence Software <>
Blog <>
perl -E '$_=q{V zrna gur orfg jvgu jung V fnl. }.
q{Vg qbrfa'\''g nyjnlf fbhaq gung jnl.};

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <>

More information about the Python-list mailing list