r/Python • • Apr 29 '20

Discussion Tab vs Spaces

Post image
702 Upvotes

72 comments sorted by

View all comments

Show parent comments

6

u/Zomunieo Apr 30 '20

Many reasons:

*If you like 2, 4 or 8 characters per tab, you can use 2, 4 or 8 spaces. Your editor should be able to change the indentation to your preference if you like.

*Sometimes people do ASCII diagrams, tables, or equations in their comments. These will get messed up with tabs unless everyone who edits them is very disciplined about using spaces and tabs appropriately. (They're not.) When done with spaces they always look consistent.

*You can't type a literal tab in web browser's text box, including Reddit's. Websites can't display true tabs and they don't work properly in copy and paste - not without some Javascript anyway.

-3

u/[deleted] Apr 30 '20

*If you like 2, 4 or 8 characters per tab, you can use 2, 4 or 8 spaces. Your editor should be able to change the indentation to your preference if you like.

No. Absolutely not. That would mean changing the whole code because of a formatting preference. If I see any of my colleagues do this, it will warrant a serious proverbial slap.

*Sometimes people do ASCII diagrams, tables, or equations in their comments. These will get messed up with tabs unless everyone who edits them is very disciplined about using spaces and tabs appropriately. (They're not.) When done with spaces they always look consistent.

This is another problem that, yes, solved with spaces. This is not indentation though. This is alignment.

Indentation is what you use for nested code. Alignment is what you do to make the = signs be under each other to be pretty.

*You can't type a literal tab in web browser's text box, including Reddit's. Websites can't display true tabs and they don't work properly in copy and paste - not without some Javascript anyway.

	what is this then

Well, without Javascript you can't really make the "Tab" character work nicely. And if you have to sit there and tap Space 12 times for code that's nested 3 levels deep, then you're definitely doing it very wrong.

4

u/[deleted] Apr 30 '20

Any modern IDE should (a) understand the user’s intent for encoding tabs or spaces, (b) translate the tab key into that intent, and (c) intelligently auto-indent in accordance with that intent based on the syntactic context.

Nobody should be hammering the space bar a bunch of times to indent multiple levels.

-1

u/[deleted] Apr 30 '20

Well obviously, that was a ridicule of the idea of typing code in a web editor that uses the tab key for switching between page elements. Have you read what I was replying to?

1

u/[deleted] Apr 30 '20

Have you read what I was replying to?

Yes, and you made similar remarks (regarding alignment vs. indenting) in other comments in this post, to which I've separately replied. If you like, I can reproduce them here.

I responded here only to address the spacebar thing. And you're not the only person to raise that argument in this post: see here.

-1

u/[deleted] Apr 30 '20

Yes

liar

I responded here only to address the spacebar thing

which you would know is not a serious suggestion, and just highlighting the ridiculousness of some of the stuff in the post that I replied to. I was writing EXACTLY why it was bad, and now you tell me it is bad.

And you're not the only person to raise that argument in this post

That wasn't my argument, not my post. You're generalizing completely different people who made completely different things, because: Have you read what I was replying to?, the answer should be "No", you didn't read.

→ More replies (0)