| > You can't let the computer ensure the correctness of code. But I'm not letting it do that, I'm letting the computer autoformat it, which it can't do if the whitespace is the code. > Then function(3) will be compiled out of the if sentence, when it's clearly part of the else block. And yet, I don't have to worry about that error because the editor is able to simply autoformat it so I can see where the error is even when the compiler/interpreter thinks it's legal code! That's the whole point - using whitespace as part of the code means that the IDE can not, and never will be able to, autoformat the code. Your example is one of a burden that falls to the programmer in Python, but is taken care off by the computer in other languages. These errors, which can be automatically found by the computer in other languages, have to be manually found by the programmer in Python. It's a clear disadvantage. |
Of course it can do it. Indentation changes are parsed as delimiters, so it can treat them in the same way as if you put those delimiters yourself by hand.
> And yet, I don't have to worry about that error because the editor is able to simply autoformat it so I can see where the error is even when the compiler/interpreter thinks it's legal code!
Nothing prevents an IDE to highlight that error through other means. Ever heard of secondary notation? You don't need explicit delimiters to apply them, when indentation changes work as delimiters themselves. Simply highlight the start and end of blocks, and you'll get the same exact benefits as with programming languages based in brackets.
> These errors, which can be automatically found by the computer in other languages,
So tell me, how would the computer find an error if you have unmatched open/closed brackets? Doesn't that mean that other computer languages have errors that can't exist in Python?
> Your example is one of a burden that falls to the programmer in Python, but is taken care off by the computer in other languages.
How does an error in C code fall to the programmer of Python?
BTW, do you understand Python block delimiters at all? Your complaint seems to come from not understanding how a Python developer sees indentation. Once you enter this mindset, indentation errors are no different than unmatched open/close brackets - which do exist in languages like C too.
> That's the whole point - using whitespace as part of the code means that the IDE can not, and never will be able to, autoformat the code.
No - it means that indentation changes are meaningful, so the state of the code before reformatting should be maintained after reformatting. As long as the reformat tool doesn't change the meaning of the Python code, it will autoformat code perfectly fine, as numerous autoformatters in existence prove.
https://www.kevinpeters.net/auto-formatters-for-python
Which is what I was referring to in my first comment - you need an IDE that understands Python syntax, not just one that blindly pairs open/close delimiters.