3 ms·
while i concur, there is one shining example where this is a problem: fixing someone else's code where a bug has been introduced due to mistaken indentation. l
by jnazario 13y ago
while i concur, there is one shining example where this is a problem: fixing someone else's code where a bug has been introduced due to mistaken indentation.
last week i fixed a bug where a mistake in indentation (maybe a cut and paste in a refactor?) caused something to be done once but not the correct number of times (once for every iteration). took a few minutes to figure out where to look, but it took a few minutes more to figure out what was intended and what the bug ultimately was (the disconnect between what you meant and what you did). while this is a small 2 line example, for larger code blocks this is a serious problem.
i'm not advocating for braces, but they have a helping hand in spotting these sorts of bugs.
that said i often dislike it when people dismiss python just on the whitespace complaint alone.
- analog31 13y agoI've committed plenty of indentation bugs in Python. But I've also committed bugs due to putting something on the wrong side of a closing brace.
- waps 13y agoPlease don't call manual copy-paste code changes refactorings. Here is the definition of refactoring : > Typically, refactoring applies a series of standardised basic micro-refactorings, each of which is (usually) a tiny change in a computer program's source code that either preserves the behaviour of the software, or at least does not modify its conformance to functional requirements. Many development environments provide automated support for performing the mechanical aspects of these basic refactorings. If you attempt to do computer's work for them, you're going to screw up. I screw up manual refactorings in Java too (e.g. misspelling variable names, misspelling one of the gazillion xml file declarations), and much more than in Python. Don't do manual refactoring. The real flaw is that the architecture of python makes automated refactoring impossible. This is not due to the indentation sensitivity of Python.
- CatMtKing 13y agoI usually run other people's code through a linter if I don't like their coding style and have to read it. It saves a lot of pain later.