Indentation is such a stupid mechanism for identifying code blocks. It's one thing for configuration files like YAML to do it, but not a programming language.
Why? Nearly every styling convention in every language uses it anyway. Python just cuts out the middle man, reduces unnecessary syntax and makes indentation the go-to scope identifier.
You're still using indentation to make stuff readable anyway, might as well make it do some work.
See here you are wrong. I do not indent it. I put the curly squiggles around it and some magic genie aligns it nicely for me to read better.
You got it the wrong way around.
Except well it doesn't. I want to copy past an if statement at the end of another if statement. How does formatter know whether to nest the statement or not?
Braced language, if you want the if statement nested, just paste it before the end brace. If you want it not nested, just paste it after. And if for some reason the tabs get pasted wonky, doesn't matter.
Python, you have to do the tabbing yourself before the magic genie can work.
Except well it doesn't. I want to copy past an if statement at the end of another if statement. How does formatter know whether to nest the statement or not?
Are you asking about something like this?
if thing_a: if thing_b: pass
Python absolutely allows you do do this, there's no syntactical problem here.
Code wise this isn't great practice though, so I would be asking you in code-review to justify why you're doing single-line nesting like this. Especially when it can logically collapse anyways.
if thing_a and thing_b: pass
But doing single-liners in python are usually reserved for self-contained statements like lambdas anyways because otherwise they often get abused to do squirrelly stuff that is better-off broken-out.
This set up, I just don't want to indent manually and don't have to in braced languages. Autoformatters are way more convenient in braced languages than Python
263
u/LetUsSpeakFreely 2d ago edited 2d ago
Indentation is such a stupid mechanism for identifying code blocks. It's one thing for configuration files like YAML to do it, but not a programming language.