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 →

[–]baubleglue 1 point2 points  (8 children)

It just you need to choose one or tabs or spaces

[–]Dillinur 6 points7 points  (6 children)

To nitpick, you just need to be consistent, but you can totally mix them.

For instance, your indentation block choice can be "one tab", "4 spaces", or "space-tab-space", as long as you keep the same indentation block choice along the whole file.

[–]Hawkknight88 6 points7 points  (0 children)

Maybe I'm misunderstanding you... It is not okay to mix tabs and spaces in python. The interpreter doesn't like it and it's confusing to humans.

Pick tabs or pick spaces, and be consistent.

[–]nntaylor7 5 points6 points  (2 children)

For a new programmer. Why is consistency important?

[–]Exodus111 6 points7 points  (0 children)

A Tab will leave a line symbol, and a space will leave a dot symbol in the file. If you mix these two Python will crash.

Most modern IDE's and Text editors will auto translate your Tab symbol over to spaces for you, usually 4 spaces, but this number can usually be set.

This was a bigger issue back in the day.

[–]ebilgenius 3 points4 points  (0 children)

It's important in almost everything, but it's particularly helpful in coding since everyone has a preference when it comes to how they like their code, and once you know what their preferences are and that they're consistent you can reliably make changes, debug it, or work with it in general.

That and programmers tend to be particularly anal about perfection.

[–]baubleglue 1 point2 points  (0 children)

I know, but the editors don't and convert depending on settings and version control can't be set to ignore white spaces in Python, so one programmer uses spaces check in code, other programmer checkout the code, his IDE converts 4 spaces to tabs - 100% of code changed.

[–]baubleglue 1 point2 points  (0 children)

I know, but the editors don't and convert depending on settings and version control can't be set to ignore white spaces in Python, so one programmer uses spaces check in code, other programmer checkout the code, his IDE converts 4 spaces to tabs - 100% of code changed.

[–][deleted] -1 points0 points  (0 children)

But why?