3 ms·
When has it ever been an issue in use? People complained about this in 1999 but then I used it and it's never mattered.
by usef- 2mo ago
When has it ever been an issue in use?
People complained about this in 1999 but then I used it and it's never mattered.
- dgellow 2mo agoIt’s an issue when generating python, I can tell you from experience. It’s also a pain to not be able to safely rely on an auto formatter
- usef- 2mo agoEvery python developer I know uses an auto formatter today, and never needs to think about it (ruff, black). It's not ambiguous and is immediately visible if something has the wrong indent. (On other projects, I often wish other languages had formatters as good and standard as the Python ecosystem. I have many complaints about Python but whitespace is just not a problem I've seen)
- dgellow 2mo agoYou missed the point. I’m well aware python has formatters, I use them and implemented my own. The point was that when generating/manipulating python code you cannot just generate in whatever format then run a formatter. you need to carefully keep track of the exact indentation at place where the code in written
- usef- 2mo agoFair. That is a very slight friction on what is quite a small niche, though (compared to the wider ecosystem of developers). And most that need similar will use AST or runtime construction. The trivial kind of raw source generation is still trivial, but I'm guessing you're doing embedding/templates or something?
- dgellow 2mo agoIt’s definitely niche!
- ameliaquining 2mo agoIf I were doing this, and the code generator was itself in Python, I'd probably use ast and/or tokenize to avoid having to manipulate literal whitespace.
- pjmlp 2mo agoToday and forever, I was using ActiveState IDEs back in the day, I started using Python in version 1.6. Also it isn't the only one, many ML derived languages also use indentation, including the famous F#, Standard ML, OCaml, Haskell,....
- ameliaquining 2mo agoPython's significant indentation does have real costs, but they mostly don't affect experienced programmers working on real codebases in real editors or IDEs. Rather, they are things like, it makes the REPL more cumbersome, and newbies sometimes find that code they copy-paste from the Web mysteriously fails to work.
- jhbadger 2mo agoHave you never tried to paste python code from the internet into an editor? At least half the time the indentation is screwed up and I have to go in and figure out manually where to put the spaces in. Indentation gets screwed up by pasting in other languages too, but with those I can generally tell the editor to reindent and it can because the information is included in the source code.
- eviks 2mo agothe solution is the same - you tell the editor to paste with an indentation adjustment
- fragmede 2mo agoGet a better editor! Yes if your tools suck, things suck. So get better tools.
- jhbadger 2mo agoI've tried them all - vim, emacs, vscode, etc. They all fail in this regard not because of themselves but because significant whitespace is a terrible idea which nearly every programming language avoids.