3 ms·
I love Python and it is one of my primary development languages, but I have come to believe meaningful indentation was a bad idea. As Rob Pike said in the rece
by keypusher 12y ago
I love Python and it is one of my primary development languages, but I have come to believe meaningful indentation was a bad idea. As Rob Pike said in the recent Go conference keynote: "It is a profound mistake to have your semantics depend on invisible characters". Braces also make parsing and auto-formatting easier and better. It seems Go struck a good balance with with a newline after statements (no semicolon necessary), and braces for all structures.
- gohrt 12y agoNewlines are invisible characters. Tabs+spaces are the real problem with python indentation. It should be a compiler error to mix them in a file.
- shurcooL 12y agoI would not classify newlines as invisible characters. Except maybe the last newline in the file. Invisible characters are those that you can't tell if they're present or not. Assuming there are visible characters following, a newline can be clearly "seen" because it shifts the remaining text one line lower.
- Someone 12y agoYou must have never encountered a file with mixed line endings. Somebody should design an esoteric language that uses LF to separate statements in a block and CRLF to separate blocks. Alternatively, find a unicode line break character that editors recognize, but C doesn't treat as a line break, and sneak it into a source file at a strategic place to introduce a back door.
- gmjosack 12y agoSemi-related, you might be interested in Whitespace http://en.wikipedia.org/wiki/Whitespace_(programming_language) http://en.wikipedia.org/wiki/Whitespace_(programming_languag...
- sanxiyn 12y agoWhile this is now impossible to fix because of backward compatibility, you can use alias python='python -tt' in your environment. Given that option, it is a compiler error(TabError) to mix tabs and spaces.
- keypusher 12y agoThis is a great tip, thanks!