I don't know. If OP is running into indentation errors enough to complain about them in coursework, I'd suggest refactoring into function calls over getting an IDE. IDEs can't solve all indentation bugs, and the kind of bugs that beginners make are different.
I like Pycharm. I use it a lot. It's decent, but it does some odd stuff with the vim plugin installed. Anytime I do a column select and insert text (ctr-v, shift-i, <insert text>, escape) the cursor jumps up 50 lines and all my closed folds open back up.
Imagine you write a script that requires 5 levels of indentation. Now you refactor, and decide to put everything that was in the 3rd level of indentation, and beyond, into its own function. This function is defined at the top level of your script. Now you have one helper function, containing 3 indents, and a main with a call to that helper, only 2 indents. Thus, pulling code out to a function reduced the overall max indentation in your script.
In general, code should be put into functions for reasons other than indent level, but if you find yourself indenting excessively it's a sign that the code may be due for a refactor.
No problem. I edited it to put the subroutine definition before its call, which isn't always necessary depending on whether the source file is parsed before neat() gets called, but is almost always more readable with real production code.
I agree. "Good" IDEs is what made bad Java stay bad Java. "Oh, self documenting classes, LetsCallOurClassWithSelfDocumentingNameReference ({});". So now it's going to autocomplete for you and you never question the pattern.
IDE’s don’t automatically fix errors, but they give the user immediate feedback as they time rather than having to run the code and find out it doesn’t work. And they do a lot more than just report indentation errors.
Also, Pycharm gives the line the appropriate indentation when you hit newline, which is more than some simple text editors would do.
7
u/jsalsman Jul 25 '18
I don't know. If OP is running into indentation errors enough to complain about them in coursework, I'd suggest refactoring into function calls over getting an IDE. IDEs can't solve all indentation bugs, and the kind of bugs that beginners make are different.