3 ms·
My problem has been that I sometimes lose indentation, by accident, and this can break or, worse, alter the behavior. It is also a nuisance when I want to copy-
by DNF2 5y ago
My problem has been that I sometimes lose indentation, by accident, and this can break or, worse, alter the behavior. It is also a nuisance when I want to copy-paste code from somewhere else, and it doesn't go smoothly.
Once I needed to incorporate code from a colleague who used 2 spaces for indentation. That was a nightmare.
- leadingthenet 5y agoYou're simply admitting to not using a formatter. Both Black or PyCharm's Ctrl+Alt+L format should be able to handle that scenario. You can enable it to run automatically on file save in either (n)vim, VSCode, or PyCharm. Or as a git hook. Or in a CD/CI pipeline. Seriously, simply installing black through your favourite package manager and running `black .` in your project directory takes like 10 seconds flat. Done, you never have to think about tabs / 2 spaces / 4 spaces ever again. Please use these tools, I promise both your own and your colleagues' life will be greatly improved, and it takes no effort at all to use.
- DNF2 5y agoIf you say so. I've never heard of either of those, and have only the vaguest idea of what a 'formatter' might be. Is it not a solution to an unnecessary problem? And how can a formatter fix a lost indentation that changes the meaning of the code? I do know for sure that my colleague will never use this, even if I might. Fortunately, this isn't an issue in the languages I use most of the time. (Another problem that's bothering me almost as much is that without brackets or `end` statements, the code looks assymmetrical - unbalanced and awkward, as if it's trailing off, having forgotten its purpose.)
- leadingthenet 5y ago> Is it not a solution to an unnecessary problem? You literally stated the problem yourself, so obviously not. Seeing how it’s an official tool by the Python Software Foundation, it should underline how critical it is. > I do know for sure that my colleague will never use this, even if I might. You gain value even if you’re the only one using it, as it solves the issue you mentioned having.
- DNF2 5y agoWhat? I mean, it's a solution to an unnecessary problem caused by indentation being significant. The problem wouldn't exist if whitespace wasn't significant, which was an unfortunate design choice. So it's a solution to an unnecessary problem.