5 ms·
> Formatting > The solution here is to always use an automated code formatter. Spot on. Python got that part right.
by kardos 11y ago
> Formatting
> The solution here is to always use an automated code formatter.
Spot on. Python got that part right.
- kqr 11y agoSurely you mean Go? There is one for Python, but it's not official.
- kardos 11y agoPython won't run without specified indentation, and leaves no freedom for brace positioning. On the C side, we've accumulated a variety of formatting styles [1]. [1] https://en.wikipedia.org/wiki/Indent_style#Styles https://en.wikipedia.org/wiki/Indent_style#Styles
- yarrel 11y agoYou can automatically format C. Python, not so much.
- kqr 11y agoBoth of you make the mistake of confusing formatting with indentation. Indentation is just a tiny part of formatting. There are tools to automatically format Python (but they do obviously require that the indentation is somewhat correct before you run them) and they work fairly well. :)
- hyperpape 11y agoMy experience is that Python handles this wonderfully on the reading side, because code will always be consistently formatted. But on the writing side, it's harder (impossible?) to have tools that format an entire file, because without braces, various things could be at different levels of indentation. You have to indent as you go, and changing the level of indentation can be a little painful. In curly brace languages, you can sometimes work very fast by crapping things onto the page and then formatting the entire file. I don't know which I absolutely prefer, but there is a tradeoff to whitespace based blocks. That said, I think C & Java suffer for the combination of optional braces and lack of a standard format tool.