Enforce “spaces” or “tabs” only in python files?

前端 未结 4 655
说谎
说谎 2021-01-13 16:38

In Python, is there a mean to enforce the use of spaces or tabs indentation with a per file basis ?

Well, perhaps \"enforce\" is too strong, more like a \"recommend

4条回答
  •  無奈伤痛
    2021-01-13 17:07

    This is something your editor should do for you. Most editors (try Notepad++ for example, it's free) will let you set whether hitting tab enters a tab character or a number of spaces. I'd recommend using two spaces instead of tab in all files (I find 4 is too much). Using spaces instead of tabs is better as it means that you can indent stuff using both the space & tab keys without worrying about messing up your files.

    If you have files that have a mix it isn't hard to write your own script to convert tabs to spaces

提交回复
热议问题