How coding in Python is bad for you

Chris Angelico rosuav at
Mon Jan 23 23:41:30 EST 2017

On Tue, Jan 24, 2017 at 3:22 PM, Steven D'Aprano
<steve+comp.lang.python at> wrote:
> But more seriously, it's easy to typo an extra indent. It's harder to typo
> "endif" when you actually meant to type, oh, "ending = 1 if condition else 3",
> say. So faced with ambiguity, and the insistence that the right way to break
> ambiguity is to guess ("Do What I Mean, dammit!!!") the most likely guess is
> that the indentation is wrong.
> But not guaranteed. That's the thing about being ambiguous -- there is a chance
> that the indentation is correct.

Indeed. I teach JavaScript as well as Python, and I've seen some
pretty horrendous indentation flaws (examples available if people ask
privately, but I will anonymize them because I'm not here to shame
students) - but there have been nearly as many cases where the
indentation's fine and the bracket nesting isn't. I probably sound
like a broken record [1] with the number of times I've said "check
your indentation", as a hint to where the missed-out close brace or
parenthesis is. True, with "endif" it's a bit harder to typo, but it's
still just as easy to make a copy-and-paste error and end up with code
like this:

if condition:

What's this code meant to do? Can't know.

Remember: If you have only one clock, it might be right and it might
be wrong, but it's consistent. If you have two clocks and they
disagree, you have no clue what the time is.


[1] Wonder how many of today's generation of programmers have actually
heard a record skip...

More information about the Python-list mailing list