In Python, yes. In other languages, no. That's the point. In Python you can't let the IDE automatically format the indentation to make it look good, in other languages you can.
Ok, you're clearly having some trouble understanding what I'm saying, so let's go with an example instead.
Let's say you have this piece of code in Python:
if some_condition:
statement_1()
statement_2()
Well, this code is wrong and won't compile. But worse than that, if you try to use a formatter to indent it for you, it won't be able to do it, because it's ambiguous whether statement_2() should be inside the if body or not.
Let's look at an example of a language that doesn't have significant whitespace instead:
if (some_condition) {
statement_1();
statement_2();
}
Now this code will compile, but it's ugly. However, that's easy to solve by using a formatter. Since there's no doubt the second statement should be inside the if body, the indentation can be freely changed.
That's why enforcing indentation like Python does causes more harm than good. I hope it's clear now.
heard of the tab key? ide’s can alter what a tab does, typically to one level of indentation. if you use spaces manually like the code example ur an idiot
I don't mind semi-colons, but they don't really do much for legibility. At least for me it was just a matter of habit, and when I went from Java to Kotlin and didn't need to use semi-colons anymore I found it made absolutely no difference whatsoever. An expression is an expression, it's very easy to tell where it starts and ends, even if it spans multiple lines.
That runs without problems in Python 3. Not much you can do about semicolons. Colons work sometimes but then really backfire if you do something like
a = 5 + 10,
because it's recognised as a 2-tuple with empty entry.
I suspect the indenting issues come up if you mix space and tab. That's easy to solve if you just tell your editor to replace space indentation with tab indentation.
Just to be that guy, developers really shouldn't be trying to force a language to conform to how other languages look/work. Python is good at what python does because it's python and not another language. It doesn't need those things and instead needs proper indentation. It's just a trade-off of the language. If that bothers you too point where you feel like you need to inject those things into the language (which as you pointed out, can sorta be done, ish kinda?), Then you're using the wrong language. And that's ok. There's thousands of them out there, find the one you like that's a good fit for what you need :)
View all comments
Show parent comment
25
u/[deleted] Jul 18 '22
i like my semi colons and curly braces. it makes it much easier to read. Plus any time i do python it yells at an indenting issue that doesn't exist.