r/Python • • Jul 25 '18

Use an IDE Me doing my CS projects.

Post image
1.2k Upvotes

213 comments sorted by

View all comments

Show parent comments

0

u/[deleted] Jul 25 '18

[deleted]

17

u/1ynx1ynx Jul 25 '18

According to pep-8, it's spaces.

0

u/[deleted] Jul 25 '18

[deleted]

10

u/mooburger resembles an abstract syntax tree Jul 25 '18

Because for the "1 char" the editor can be configured to show it as how many character spaces it chooses. This makes tabs visually inconsistent. If I open a file in an editor and I suddenly see 2 spaces (that is 1 tab) but in a different editor (or in the terminal; or both (vi, emacs, etc.)) I look at the same file and it's 4 spaces, that violates POLA.

Whereas with spaces you know what indentation level you're at when looking at the code in any visual format, since it's always the same as 4 space widths characters worth of space..

1

u/BillyWasFramed Jul 26 '18

Serious question, why don't we want the developer to have control over the indentation level? Why is it preferable that you get to control the indents on my screen? What if I prefer 2 and you prefer 4?

2

u/TrixieMisa Jul 26 '18

PEP-8 again. 4 spaces.

1

u/BillyWasFramed Jul 26 '18

Does PEP-8 answer the question I just posed?

→ More replies (0)

1

u/mooburger resembles an abstract syntax tree Jul 26 '18

because in the real world, other people than you will probably need to be able to read your code.

1

u/BillyWasFramed Jul 26 '18 edited Jul 26 '18

Oh look, a condescending non-answer. why not use tabs and let me worry about indentation? Are you not answering because there isn't a good answer? If it were really about readability, why wouldn't you use the character that allows me to decide what's readable? You have tabs set to 4? Congrats. You're using 4 spaces. I have tabs set to 2? Congrats, I'm using 2 spaces.

→ More replies (0)

1

u/crunk Jul 26 '18

Because the majority of projects involve more than one developer.

Imagine if spaces and tabs are mixed (which invariably happens if one person uses tabs).

1

u/XtremeGoose f'I only use Py {sys.version[:3]}' Jul 26 '18

Becuse if I've done something pretty where I've alligned function arguments or a dictionary literal:

def f(arg1,
      arg2):
    d = {
         'x': 1,
         'y': 2
        }

And you come along with a different tab width you might see something like this:

def f(arg1,
           arg2):
         d = {
                 'x': 1,
                 'y': 2
                }

Which is easier to read for you?

1

u/BillyWasFramed Jul 27 '18

Yeah this example makes the most sense. You can't just do tabs for indention and spaces for alignment and not end up with code like this. Even if you could, it would be impossible to enforce...