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.
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.
My editor turns tabs into 4 spaces. No more “mixing tabs and spaces” errors afterwards.
Better than counting curly braces.
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.
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!
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
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.
Python syntax is the absolute worst
Not the previous commenter, but using indentation as syntax rather than an aid to understanding tge program structure is just painful when you come from any more conventionally structured language. The meme above may be an exaggeration, but it’s not much of one. An IDE can probably help, but needing one just to be able to more easily read the code is excessive.
That said, it’s a popular language and there are plenty of useful libraries, so sometimes the trade off is worth it.
Coming from C++ and Java over to Python was challenging. The IDE I used at the time also did not like when I used tabs instead of spaces, which drove me up a wall.
I will say that for beginners where python is their first language, it does a good job at reinforcing good practices for writing legible code.
I even coded my first few python programs in nano text editor without any annoying indentation issues. I use TABs btw. Problems usually happen when people mix tabs with spaces
I’ve programmed Python mostly without IDE without any problem. It’s no more difficult to understand the structure of the program than a bracketed language.
To each their own. If I’m going to bother intending all of my code may as well benefit from it. I don’t actually use Python that much and don’t love it but I am a fan of significant indentation. But most honestly it isn’t a big deal either way. While I would be happier if my preferred language had significant indentation it is very unlikely to be something that convinces me to use a language or not.
And that is why I don’t bother with that garbage. C++ for life
Programming languages that use white space to delimit structure are annoying at best. I get annoyed at yaml too, but I’m ok once I have a few templates set up.
Why tabs suck? Explain.
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!
YAML comes with its own unique pains in the ass https://ruudvanasseldonk.com/2023/01/11/the-yaml-document-from-hell
These things actually matter, come up often enough to actually be annoying, and are a bit difficult to explain and learn into people. You’re basically fine if you just string quote everything that you can, but nobody does that.
That was interesting. And possibly the most Dutch name I have ever heard of.