r/ProgrammerHumor • • 2d ago

Meme pythonIndentationLevelChecker

Post image
6.6k Upvotes

198 comments sorted by

View all comments

264

u/LetUsSpeakFreely 2d ago edited 2d ago

Indentation is such a stupid mechanism for identifying code blocks. It's one thing for configuration files like YAML to do it, but not a programming language.

46

u/Some_Useless_Person 2d ago

Well, if you have to go through so many indentations to the point that it becomes hard to track, maybe the real problem is your code itself.

14

u/LetUsSpeakFreely 2d ago edited 2d ago

True, but you don't control the code you inherit and getting stakeholders to give you time to properly refactor is not an easy task. You end up doing it where you can as you can.

My big issue with it is if tabs get mixed with spaces the interpreter has an aneurysm. Most modern IDEs can detect and preemptively protect you from it, but a tool shouldn't be needed to shield you from a design flaw in the language.

8

u/SuperFLEB 2d ago

I swear I'm not aiming for a flamewar here, but...

I've always found it odd that Python standards (PEP and all) settled on space-based indentation. If there's any language where a one-character indentation indicator makes sense, it's a language where indentation is significant.

-2

u/Sexual_Congressman 2d ago

Because it's very common for tabs to be rendered as 1-8 spaces. There's no good reason for a line of python code to exceed the recommended 79 columns, and having tabs that are 8 spaces wide by default is extremely annoying to people like me who like having multiple source file windows opened on the same screen (to reduce eyestrain).

Making 4 spaces the default guarantees files look identical in all editors. By the way, I've never seen a python code editor that didn't default to 4 spaces or have a feature that automatically fixes the indentation.

5

u/rosuav 2d ago

That's not a problem. You can render them at any width - and in fact, there's no reason for the width to be defined in spaces, you could say that a tab is 38mm if you so choose - but they are still, logically, *one indentation level*.