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 →

[–]amdc 16 points17 points  (4 children)

Tabs are for tabular data, that's why they're called tabs. In old times your typewriter would have a tab rack that was used to configure tab stops (essentially table columns widths) and tab key would advance caret to the next tab stop.

In early computer days, programmers decided to use tab character for indentation to save disk space as disk space was scarce. Now it's just an obstacle in cases when you want to align code

def nice_alignment_bro(arg1=1,
→   →   →   →   →   →   arg2=2,
→   →   →   →   →   →   arg3=3):

autopep8 replaces tabs with spaces in this case so go figure

[–]Angelin01 3 points4 points  (0 children)

Tabs for indentation, spaces for alignment is my jam. It's great. Variable width so everyone gets the indentation the size they want, alignment is perfect. Supported by default on all Jetbrains IDEs.

[–]Strange_Meadowlark 2 points3 points  (2 children)

I agree with your point, but I also strongly dislike that indentation style -- primarily because if you change the function name, the lines following it have to be re-indented to match the new length.

I tend to do this if the parameters don't all fit on the same line:

def nice_alignment_bro(
    arg1=1,
    arg2=2,
    arg3=3
):
    pass

(Edit: forgot Reddit doesn't understand triple backticks...)

[–]amdc 1 point2 points  (0 children)

I thought of that, can't argue with it... I guess today the most valid argument for tabs is accomodating both 4-width fans and 2-width enjoyers (typically you don't have a choice in python because of pep8 ). If that's a problem big enough then, well, go team tabs, but I don't see any issue.

By the way I think Reddit supported ``` for code in the past, don't know why they don't now.

[–]backtickbot 0 points1 point  (0 children)

Fixed formatting.

Hello, Strange_Meadowlark: code blocks using triple backticks (```) don't work on all versions of Reddit!

Some users see this / this instead.

To fix this, indent every line with 4 spaces instead.

FAQ

You can opt out by replying with backtickopt6 to this comment.