tags:

views:

74

answers:

2

Edit: This question has already been asked and answered, and I apparently am not good at using the search wizard. See http://stackoverflow.com/questions/120926/why-does-python-pep-8-strongly-recommend-spaces-over-tabs-for-indentation and the link in the comments. Thanks for replying to those who did so.

I want to start a new project, and I want this to be my first Python project. I was looking through the style guide, http://www.python.org/dev/peps/pep-0008/, which "strongly recommends" using a 4-spaces indentation style for new projects. But I just hate this idea! In my opinion, tabs are better for this purpose.

What annoyances could crop up one day if another developer wanted to work on my tab-delimited files?

+1  A: 

Most Python programmers will have their editors configured to automatically use four spaces for all .py files… Which could, at least initially, cause some minor headaches if they try to edit your source.

But apart from that (given that PEP 666 was rejected), it shouldn't cause any major trouble.

Of course, if you get serious about Python, it would be a good idea to follow PEP 8, as most Python code conforms to it… But, given that this is your first Python project, you've got bigger things to worry about than tabs VS spaces.

David Wolever
+1  A: 

If all the world used tab-indented Python source, then everyone would be happy. If all the world used 4-space indented Python source, then everyone would be happy.

Unhappiness arises when one tries to comingle tab-indented code with 4-space indented code.

The majority of Python code seems to be of the 4-space variety. If you ever wish to rip out some of this code and use it in your project, you will be saved from the minor annoyance of having to run it through a space-to-tab converter (like unexpand) if you stick with the PEP recommendation and use 4-spaces.

You'll also cause less of a hassle for other developers (who follow the 4-space convention) who may wish to contribute to your project.

PS. Finding a good text editor is especially important when writing code in Python. It should allow you to press [TAB] and insert 4 spaces instead of 1 tab. It should also allow you to be able to shift blocks of code by 1 level of indention to the left or right easily. Once you find the right editor (e.g. emacs or vim), working with the 4-space convention is a breeze.

unutbu