Python indentation in “empty lines”

前端 未结 10 2074
野性不改
野性不改 2020-12-29 18:29

Which is preferred (\".\" indicating whitespace)?

A)

def foo():
    x = 1
    y = 2
....
    if True:
        bar()

B)



        
10条回答
  •  长发绾君心
    2020-12-29 19:07

    vi implicitly discourages the behaviour in A because the {/} navigations no longer work as expected. git explicitly discourages it by highlighting it in red when you run git diff. I would also argue that if a line contains spaces it is not a blank line.

    For that reason I strongly prefer B. There is nothing worse than expecting to skip six or so lines up with the { motion and ending up at the top of a class def.

提交回复
热议问题