The ONLY piece of information that is available to you regardless of how deep you are into a function is INDENTATION. Your curly braces won't help you.
Besides that, you should seriously reconsider your coding style if this is an actual problem for you.
...No? It sounds like you write very long, messy code blocks. Consider the following example, I will write a nested loop in 2 languages:
In Python:
for _ in range(10):
for _ in range(10):
print("Inner")
print("Outer")
Here's something similar in JS: for (const _ of foo) {
for (const _ of foo) {
console.log("Inner");
}
console.log("Outer");
}
In isolation, while I'm writing this comment, I would say these code blocks are equally easy to parse. In the context of frantically debugging, scurrying around a file, I may (and have!) missed the indentation difference in the Python example.Curly braces allow me to have 3 visual indicators that a block is finished: a visual text object (the brace itself), an extra line separator (the closing brace lives on its own line), and indentation. In Python, I only have one of those things (just indentation). I can have 2 (indentation + line sparation) if I always insert a newline before `print("Outer")`, but empty lines can get deleted and I may forget to include them as I write code. You'd need to configure a linter to guarantee the line separation indicator in a language that delimits scopes by whitespace.
Obviously. You're using 2 spaces indentation for Python and 4 for JS. Don't be surprised that it is harder to see the indentation.
I think I might have indentation related bug early on, when I was new to Python, but I don't remember any recently. It could be that Python 2 allowed to mix tabs and spaces for indentation, while this is no longer allowed in 3.
Also this is how I would format the code:
for _ in range(10):
for _ in range(10):
print("Inner")
print("Outer")Also, I didn't say it was impossible to navigate, but it is cumbersome and annoying. Forced whitespace sucks.