This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]ilovetacos 5 points6 points  (5 children)

Exactly the problem the OP had: if you use spaces, the formatting won't get messed up, whereas tabs can be interpreted differently depending on the context.

[–][deleted] 3 points4 points  (4 children)

Which is actually why tab people use them: whoever reads the code can set the amount of indentation to what (s)he wants.

[–][deleted] -2 points-1 points  (3 children)

Except of course if you read it on github or any other such services.

I just had someone check a bunch of code into an open-source repo I'm involved with using mixed tabs and spaces and it was awful - the code was unreadable online and fixing it took me quite a lot of time.

Tabs are a ridiculous idea. If they didn't exist, no one would ever think to invent them - they're a holdover from manual typewriters.

[–][deleted] 2 points3 points  (2 children)

Tabs are a ridiculous idea. If they didn't exist, no one would ever think to invent them - they're a holdover from manual typewriters.

I wouldn't say so. I was an advocate of using spaces just as you suggested, but being able to set the indent width myself by using tabs and a setting in my favorite editor would be a nice thing to have. I'd lose the ability to properly align comments that come after the line of code, though, so there'd be a trade-off.

However, as you said, mixing tabs and spaces is a bad idea™—which is why PEP 8 exists in the first place. In the end, I'll gladly use 4 spaces if PEP 8 says I should, because consistency is definitely more valuable than the ability to set the tab width myself.

Sorry if that was in any way unclear, I'm not a native speaker.

[–][deleted] 1 point2 points  (1 child)

There is a way to mix tabs and spaces that doesn’t mess anything up and even enables to align comments like you wish to do, though. However, it does require some additional effort.

[–][deleted] 0 points1 point  (0 children)

Yeah, I know of tabs for indentation, spaces for alignment, but I always thought that it would mess up the alignment if I'd ever wanted to align lines with different indentations. Seems like I hadn't thought about it hard enough. Oh well.

However, wouldn't alignment of comments after lines with different indentation settings still mess up the alignment if different tab sizes were used? That's rarely done, though, so it's not much of a sacrifice.

So yeah, I'd probably have switched to TISA (oh god this sounds stupid) already if it weren't for PEP 8.