@alphacyberranger
This is why I have my VSCodium set to highlight all indentation levels in my settings.json
To see the editor indent guides, set “editor.guides.indentation”: true and “editor.guides.highlightActiveIndentation”: true.
editorIndentGuide.background: Color of the editor indentation guides.
editorIndentGuide.activeBackground: Color of the active editor indentation guide.
Here’s the relevant section of my settings.json
json { "workbench.tree.renderIndentGuides": "always", "workbench.tree.indent": 15, "editor.guides.indentation": true, "workbench.colorCustomizations": { "editorIndentGuide.background": "#fd6bff", "tree.indentGuidesStroke": "#fd6bff" } }
spaces or tabs
Tabs. But really with modern IDE it’s irrelevant. Whatever the tech lead says I guess.
With things like black, flake 8 and Isort I can code however I want, list/format however I want, and commit team compliant content. The dream is real
I love such formatters and wish they were even more widespread. In many cases, I really want consistency above all and it’s so dang hard to achieve that without an opinionated formatter. If the formatters isn’t opinionated enough, it just leads to countless human enforced rules that waste time (and lead to an understandable chorus of “why can’t the formatter just do that for meeeee”).
Yeah but outside of that where the code is implemented or in a documentation, tabs are still easier to look through. And it does look pretty as long as there aren’t too many nested functions.
Even with nested functions tabs are neat.
Does you app have too many nested functions?
Use tab width = 2
Do your app have too less nested functions?
Use tab width = 8
Is your app having average number of nested fns?
Use tab width = 4(mostly default)
And all theese can happen without modifying a single byte in the source file, unlike spaces!
4 Spaces, then one tab, then 3 spaces, then 2 tabs, then 2 spaces, then 3 tabs…
Python supports that (and I hate this)
Not any standard (and actually not at all something to do for real), but try it, it works
def magic(a, b, c):
if a > 0:
if b > 0:
if c > 0:
return 'All positive'
return 'Not all positive'
print(magic(1,2,3))
print(magic(-1,1,2))
print(magic(1,-1,0))
print(magic(-1,-1,-2))
(you should be able to verify I used both tab and spaces f*cking bad way in this example, like I described)
Output:
All positive
Not all positive
Not all positive
Not all positive
** Process exited - Return Code: 0 **
Press Enter to exit terminal
Better than counting curly braces.
There’s a joke here about using echo "some python code" > main.py
in here somewhere but I can’t find it. Imagine I did instead.
Is mirco a little man sitting on your SSD flipping bits manually as you dictate him?
Because Python uses indentation instead of curly brackets, which is why this meme exists. Also jetbrains ide s like pycharm and webstorm do all of this for you.
Even the mosy basic text editors does indentation for you, not even an IDE needed
Me too, any day. I hate everything where indentation matters. Let me just throw my garbage there and YOU sort it out, you are the fucking computer, not me. You do the work.
So fuck you, YAML! All my homies love JSON!
Yup.
Spaces? Tabs? Don’t care, works regardless.
Copied some code from somewhere else? No problem, 9/10 times it just works. Bonus: a smart IDE will let you quick-format the entire code to whatever style you configured at the click of a button even if it was a complete mess to begin with, as long as all the curly braces are correct.
Also, in any decent IDE you will very rarely need to actually count curly braces, it finds the pair for you, and even lets you easily navigate between them.
The inconsistent way that whitespace is handled across applications makes interacting with code outside your own code files incredibly finicky when your language cares so much about the layout.
There’s an argument to be made for the simplicity of python-style indentation and for its aesthetic merits, but IMO that’s outweighed by the practical inconvenience it brings.
Have you tried using an auto formatter? Let’s you write code however and fixes the structure automatically on save. It’s way easier for me to write curly braces then hit ctrl+s than have to select multiple lines manually and tab in and out. I feel the biggest gains I’ve made in productivity came after I learned to embrace tooling.
Most disingenuous post ever.
The image shown is a dude with a browser dev console, probably measuring a div for the its CSS size (which do support centimeters and inches).
In python, 4 spaces is just enough spacing between indent levels. And if your levels get too deep it’s a sign that you’re not being pythonic. Nesting too deep is the problem, not the whitespacing being significant.
Python are fine with whatever number of spaces you want to use. You can use 8 spaces which forces you carefully consider each nest, you can use 1 if you’re a monster, or you can use tabs if you’re enlightened, python only demands consistency.
Yeah I remember picking up a script after a reinstall, and gedit had reverted to default settings. It’s fun trying to spot whether it’s 1 tab or 4 spaces. After that day, I switched to two spaces as my default.
My editor turns tabs into 4 spaces. No more “mixing tabs and spaces” errors afterwards.
I normally love tabs and it’s what Go uses both by convention and it’s semi opinionated formatter. But PEP-8 suggests spaces and ultimately, consistency is more important.
Not having to argue about tabs vs spaces lets us focus on the real problems, like vim vs emacs.