4 ms·
>but white space just is not one of them. This position is hard to maintain after you've spent an hour trying to debug a nonsensical error just to realize you
by hackinthebochs 8y ago
>but white space just is not one of them.
This position is hard to maintain after you've spent an hour trying to debug a nonsensical error just to realize you opened the python file in an editor that used a different tab/space setting than the file was created in. Significant whitespace is one of the biggest misfeatures in programming history.
- goto11 8y agoSurly that could only happen if you used a mixture of tabs and spaces for indentation.
- hackinthebochs 8y agoThe point is that if you open a file with a different editor it was created with, its very easy to mix tabs and spaces without any kind of indication that that's what is going on.
- randomsearch 8y agoAnecdotally, from several sources teaching in tech, it’s the significant white space that makes python much more approachable to non-nerds. For some reason matching nested braces isn’t palatable to them. I attribute Python’s wide adoption in the non-nerd world in part to this (the other part being the ecosystem).
- JimDabell 8y agoI've been writing Python for over 20 years, and I don't think this has happened to me one single time. I'm not some kind of super programmer; I make as many mistakes as anybody else and spend too long debugging stupid mistakes occasionally. I've mixed spaces and tabs before on a handful of occasions, and it's always told me straight away what the problem is. Here is an example of mixed spaces and tabs for indentation: https://repl.it/repls/NegativeExemplaryBackups https://repl.it/repls/NegativeExemplaryBackups You'll see that it raises an error: TabError: inconsistent use of tabs and spaces in indentation …and points you to the exact line with a problem.
- hackinthebochs 8y agoIt's nice when it does offer that specific error, but I've burned many hours over the years when it fails to recognize that as the issue.
- hackinthebochs 8y agoHere's an example of an incomprehensible error related to mixing whitespace, where its not obvious its a mixed whitespace issue: https://repl.it/repls/MotionlessLustrousScan https://repl.it/repls/MotionlessLustrousScan
- JimDabell 8y agoAre we seeing the same thing? IndentationError: unindent does not match any outer indentation level The very first thing I would look at is the indentation if I got an error like that. You hardly need to "spend an hour trying to debug a nonsensical error" when you see an error like that.
- hackinthebochs 8y agoDoes "indentation error" immediately scream check for a whitespace mismatch to you? Because it doesn't to me.
- JimDabell 8y ago"Indentation error" screams "fix the indentation", and code is indented with whitespace, so yeah. When something tells you "indentation error", where's the first place you would look, if not the indentation? When you know you have a problem with the indentation, what do you think you have to change, if not the whitespace? There isn't a lot of opportunity to go in the wrong direction here. Don't get me wrong, Python definitely has unexpected, difficult to debug behaviour for newbies (e.g. mutable default arguments). But this in particular isn't one of them. This is 2+2=4 level stuff.
- 8y ago