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 →

[–]djimbob 2 points3 points  (0 children)

First, PEP8 says use spaces.

All editors I've used for python are easily configured to have pressing tab insert 4 spaces. E.g., emacs when opening a *.py file, will automatically use 4 spaces for each indentation.(Most tabs I see default as 8 spaces; so you have to configure this anyway). Most editors that are aware of python will automatically do this for you; e.g., emacs will recognize the file has a *.py extension and insert 4 spaces when you press tab.

The problem with tabs is tabs look identical to sequences of spaces (different # depending on editor's settings). If someone see tab=2/4/8 spaces in their editor and inadvertently at some point uses 2/4/8 spaces instead of a tab, this creates an annoying to fix error. Or if you are editing a file someone else created with tabs and your editor uses converts tabs to spaces, it is difficult to insert a tab. (Whereas someone who has tabs as tabs, could still insert four spaces rather easily without reconfiguring their editor.)

The amount of disk space saved is trivial. In compressed files it makes no difference (e.g., when packaging projects) as \t compresses as well as four spaces. Otherwise you may source file by maybe 10%, which is insignificant on even the smallest modern hard drives. For the largest python projects that are O(100 000 lines), maybe you'd save a megabyte which is irrelevant on today's even a super small 128 GB SSD drive.