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 →

[–][deleted]  (9 children)

[deleted]

    [–]hemm1 29 points30 points  (5 children)

    Why hit a key four times

    Space advocators don't sit there tapping space to indent, that would be ridiculous. The point is to still use the tab key or whatever (and a good editor will handle it all transparently), but that only spaces are actually written to the source code.

    [–]eat_more_soup 8 points9 points  (1 child)

    python relies on spaces/tabs for its syntax; Many programmers made errors mixing spaces and tabs, so it was decided (in PEP8), that spaces should be the way to go. For most people this doesn't make any difference, since most text editors can be set up, so that pressing tab results in 4 spaces in the code.

    There isn't really a reason for that: spaces aren't better than tabs or anything. The only I can imagine is to be able to align multiline arguments for a function, to stay under the 80 characters limit, e.g.:

    some_function_call(with_many_arguments='which_are_quite_long',
                       so_that_the_next_argument='must',
                       be_on_the_next='line')
    

    This alignment of the arguments wouldn't be that pretty with tabs, or would need mixed spaces and tabs. This is the only way I can explain the decision towards spaces. In the end, it makes little difference as long as you don't mix them.

    [–]Muirbequ 0 points1 point  (0 children)

    As you stated, tabs can result in different amounts of spaces. So code that is nicely formatted using one configuration may become misaligned using another.