Are there any pitfalls with using whitespace in Python?

后端 未结 17 1381
时光取名叫无心
时光取名叫无心 2021-01-06 17:36

At the moment I have never had a problem with whitespace in Python (although I\'ve only used it in two projects and I was the only programmer). What are some potential pitf

17条回答
  •  醉酒成梦
    2021-01-06 18:14

    Pick a good editor. You'd want features such as:

    1. Automatic indentation that mimics the last indented line
    2. Automatic indentation that you can control (tabs vs. spaces)
    3. Show whitespace characters
    4. Detection and mimicking of whitespace convention when loading a file

    For example, Vim lets me highlight tabs with these settings:

    set list
    set listchars=tab:\|_
    highlight SpecialKey ctermbg=Red guibg=Red
    highlight SpecialKey ctermfg=White guifg=White
    

    Which can be turned off at any time using:

    set nolist
    

    IMO, I dislike editor settings that convert tabs to spaces or vice versa, because you end up with a mix of tabs and spaces, which can be nasty.

提交回复
热议问题