28 points

@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.

https://code.visualstudio.com/api/references/theme-color

permalink
report
reply
1 point

Can you please share a screenshot of how this looks like?

permalink
report
parent
reply
2 points

@Toldry

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" } }

@alphacyberranger

permalink
report
parent
reply
15 points

spaces or tabs

permalink
report
reply
13 points

Tabs. But really with modern IDE it’s irrelevant. Whatever the tech lead says I guess.

permalink
report
parent
reply
8 points

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

permalink
report
parent
reply
1 point

Wait wait wait, what is this black magic and how have I not heard of it?

permalink
report
parent
reply
1 point

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”).

permalink
report
parent
reply
2 points

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.

permalink
report
parent
reply
1 point

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!

permalink
report
parent
reply
16 points
*

Doesn’t PEP 8 say spaces somewheres?

permalink
report
parent
reply
15 points

4 spaces, although I’ll die on the hill that tabs should always be used instead of space for indentation. Not just in python.

permalink
report
parent
reply
6 points
*

Questions like that are likely to start a war

permalink
report
parent
reply
5 points

semicolons

permalink
report
parent
reply
4 points

Full colons

permalink
report
parent
reply
1 point

4 Spaces, then one tab, then 3 spaces, then 2 tabs, then 2 spaces, then 3 tabs…

Python supports that (and I hate this)

permalink
report
parent
reply
1 point
*

Please elaborate (eg which standard is this defined in?)

permalink
report
parent
reply
1 point
*

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
permalink
report
parent
reply
0 points

“indentation is indentation!” (mr_incredible_cereal.jpg)

it may look messy, but would you actually rather Python didn’t support some inconsistency when the intent is clear?

being exact just for the sake of being pedantic isn’t useful.

permalink
report
parent
reply
15 points
  1. Use tabs.
  2. Enable visible whitespace.

Tada, your indentation level is nicely visible.

permalink
report
parent
reply
1 point
Deleted by creator
permalink
report
reply
68 points

Better than counting curly braces.

permalink
report
reply
7 points

parentheses

permalink
report
parent
reply
27 points

Even vim can show you that
^(fucking nano user)

permalink
report
parent
reply

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.

permalink
report
parent
reply
11 points
*

Import python.Joke.ShellProgramming()

permalink
report
parent
reply
9 points

“the punchline is clearly trivial, the set-up is left as an exercise for the reader”

permalink
report
parent
reply
6 points

Obligatory mirco is better.

permalink
report
parent
reply
11 points

Is mirco a little man sitting on your SSD flipping bits manually as you dictate him?

permalink
report
parent
reply
1 point
Deleted by creator
permalink
report
parent
reply
4 points

Why not both

permalink
report
parent
reply
4 points

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.

permalink
report
parent
reply
0 points

Even the mosy basic text editors does indentation for you, not even an IDE needed

permalink
report
parent
reply
1 point
Deleted by creator
permalink
report
parent
reply
48 points

I’ll take the curly braces

permalink
report
parent
reply
28 points

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!

permalink
report
parent
reply
14 points

All your homies hate comments.

permalink
report
parent
reply
15 points

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.

permalink
report
parent
reply
1 point

But, nobody ever copies code from Stack Overflow!

permalink
report
parent
reply
19 points

if you have to count the curly braces I understand why you are a python developer

permalink
report
parent
reply
2 points

yep.

permalink
report
parent
reply
8 points

You don’t usually count them. They just have to form a neat diagonal.

permalink
report
parent
reply
3 points

Also, highlighted the way you expect when you click next to braces works too.

permalink
report
parent
reply
1 point

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.

permalink
report
parent
reply
19 points
*

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.

permalink
report
reply
17 points

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.

permalink
report
parent
reply
2 points

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.

permalink
report
parent
reply
2 points

All theese indentation issues arises from using spaces instead of tabs. And tabs are really flexible so that everyone can set their text editor to whatever tab length they want and still be consistant

permalink
report
parent
reply
2 points

Why not TABs? I hate 4 spaces cuz it can get real messy sometimes.

permalink
report
parent
reply
1 point

My editor turns tabs into 4 spaces. No more “mixing tabs and spaces” errors afterwards.

permalink
report
parent
reply
3 points

Thats the problem. Then you commit. I clone it. I can’t use tabs because you turned everything into spaces. Why not turn spaces into tabs?

permalink
report
parent
reply
1 point

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.

permalink
report
parent
reply
1 point

I am aware but don’t know why four spaces is suggested. Tabs are consistant and flexible. Using spaces might cause errors in number of spaces and makes code messy.

Also emacs for the win

permalink
report
parent
reply
2 points

This post on programmer humor is now funnier as a result of your analysis. Everything is funnier when it is 100% accurate.

permalink
report
parent
reply

Programmer Humor

!programmer_humor@programming.dev

Create post

Welcome to Programmer Humor!

This is a place where you can post jokes, memes, humor, etc. related to programming!

For sharing awful code theres also Programming Horror.

Rules

  • Keep content in english
  • No advertisements
  • Posts must be related to programming or programmer topics

Community stats

  • 5.3K

    Monthly active users

  • 1K

    Posts

  • 38K

    Comments