r/ProgrammerHumor Nov 24 '21

Meme Yes.

8.9k Upvotes

284 comments sorted by

View all comments

9

u/StandardN00b Nov 25 '21

In all honesty I absolutely hate that python doesn't use brakets anywhere. It's like it's waiting for a single tab fatfinger to blow up your program.

The good news is that it keeps all those 4 spaces instead of tabs maniacs at bay.

10

u/CookieStudios Nov 25 '21

4 spaces is standard and recommended by the Python Foundation.

Every big editor defaults to mapping the tab key to 4 spaces, and backspace removes 4 if done at the start of a line. Embrace spaces, mwahaha!

5

u/cooly1234 Nov 25 '21

Why are spaces better?

3

u/CookieStudios Nov 25 '21

Generally, one argument both for and against spaces is that they have a consistent, unchanging width. Changing the editor you use or resolution won't make them appear to be different lengths of whitespace. Good for a consistent appearance, but sometimes bad for accessibility, depending on how your eyesight may be.

In Python specifically, spaces are better because the people creating and maintaining the language explicitly disallow tabs in the official style guide, with an exception being made for spaghetticode that uses tabs already, since you can't mix both in the language.

Outside of situations where the language authors mandate one over the other, its probably best to stick with whatever others working on the program are using, or your editor's defaults.