3 ms·
Yes. There are two indicators for parsing Python blocks: indent and dedent. They're the same as { and }, and easily parsed by a machine. Just not by a regex, w
by falcolas 7y ago
Yes. There are two indicators for parsing Python blocks: indent and dedent. They're the same as { and }, and easily parsed by a machine.
Just not by a regex, which so many formatting tools rely upon.
- profsnuggles 7y agoBut if I have if (test) do this; if (test) do that; and run it through a prettifier I end up with if (test) do this; if (test) do that; (Possibly I don't write a lot of c, and when I do I always use {} even if it's a single line statement) In python if I had a similar mis-indented construct how could you possibly know if it is supposed to be a nested if statement or not? I'm not picking on python I'm curious. My preferred language is clojure. I feel like the python whitespace is probably like lisp parens. It doesn't matter after the first week of learning. But when I'm typing clojure in emacs I don't care about formatting my code at all. Emacs sees the parens and indents correctly for me whenever I hit enter. I could probably write all my code on one line, run it through a code formatter and get a reasonable result. On the rare occasion I'm fixing some python when I start a new line I sometimes need to think about indenting and tab cycle until I hit the right depth.