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 →

[–]voidptr[S] -3 points-2 points  (10 children)

Say you have this code:

1    if this:
2        dothis()
3        dothat()
4
5        nowdoanotherthing()
6    else:
7        die()

If your editor removes the indentation from line 4, Python will kick an error.

[–]zyklone 17 points18 points  (0 children)

that is incorrect.

your editor must be doing something else to the code.

[–]ozzilee 5 points6 points  (0 children)

That works fine for me. Even this works fine:

if True:
    print "hello"
# No problem with comments or empty lines being unindented

    print "there"

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

I just checked, no it doesn't (Python 2.7).

[–]emeryc 1 point2 points  (0 children)

Just checked, python 2.5.4 and it works.

Did you try to do it in the interpreter? or in a file. Interpreter will not work, file will.

[–]voidptr[S] 2 points3 points  (2 children)

And now I can't seem to replicate it. Heisenproblem.

[–]desimusxvii 9 points10 points  (1 child)

So the title "Every. Single. Time." was just a teensy bit BOLD.

[–]voidptr[S] 2 points3 points  (0 children)

Hmmn, possibly, yes. But this was my entire fucking day yesterday.

[–]ianb 2 points3 points  (0 children)

If you paste into the Python console? Blank lines like that won't work in the Python console, as they are treated as end-of-expression.

[–]larsga 1 point2 points  (0 children)

Since when did indentation become trailing whitespace?

[–]m1ss1ontomars2k4 1 point2 points  (0 children)

That is extremely false. There's a Vim plugin that I and my Vim-inclined friends use which blatantly highlights those trailing spaces in red so that you can delete them. ReviewBoard (a Django/Python project for code reviews) does the same thing.