Many programmers, upon first encountering Python, are immediately put off by the significance of whitespace. I've heard a variety of reasons that this is inconvenient, but I've never heard a complaint from a Python programmer.

Of course, I haven't met a lot of Python programmers, as I have spent my career in the Java world.

So my question is for those of you that have participated in a large Python project (more than 3 months, with Python being the primary language used): Did you find the whitespace issue to be inconvenient and continually annoying? Or was it a non-issue once you got in the flow?

I'm not asking the question because I'm for or against Python, or for or against its use of whitespace. I happen to like Python, but I've never used it for anything big.

Please don't provide speculations if you are not experienced in Python.

  • 2
    Would they be using the language if they did? I wouldn't. Annoying/distracting syntax requirements is one of the of things that might make me choose a different language for a project (assuming, of course, that I can choose). – user7043 Apr 9 '11 at 21:13
  • since when is the whitespace an issue? :-) – Kugel Apr 9 '11 at 21:27
  • 22
    We find it inconvenient that everyone else keeps bringing it up. We never think about it. – Winston Ewert Apr 9 '11 at 21:37
  • The issue of whitespace is no different to years ago - OCCAM2 had significant white space. It was no big deal. – quickly_now Apr 10 '11 at 6:48
  • 4
    The only time I've ever found it annoying is when copy-pasting code from online which was written using spaces instead of tabs (or vice-versa), causing literally invisible syntax errors – Cameron Apr 10 '11 at 7:32

10 Answers 10


There is only one case in which I find the whitespace to be annoying, and that is when modifying existing code so that a block of code has to become more or less indented than before (e.g., adding or deleting an if: before the code). When writing in a language like C, you just add the if and a pair of braces, and (in Emacs, or I imagine any good editor) press Tab to let the editor automatically correct the indentation. In Python, you have to do it yourself. Of course, there are editor shortcuts to do it yourself, so it's not so bad, but the loss of redundancy does impose a slight extra burden on the programmer.

On the whole, it's a win, though, if only for preventing half of my screen from being filled with lines like the following:

  • 1
    In any reasonable editor that speaks Python, there is a very easy way to reindent block of code. In Wing IDE, I just select the block and hit Tab (or Shift-Tab to decrease the indent level). – Adam Crossland Apr 9 '11 at 21:35
  • 1
    Yes, in Emacs I select the block and hit C-c > or C-c <. You still have to do it yourself, though. To put it another way, since whitespace and code logic are not redundant, you can't just select a giant block and call M-x indent-region (or whatever your editor's version is) to indent it all "correctly". – dfan Apr 9 '11 at 21:39
  • 6
    @Adam, a good editor makes it easier to change your indentation level. But in a braces language, you can paste new code in, and hit your favorite keystroke to reindent the file. Tada! Indentation is correct. In python, you have to paste, select, indent/dedent. Its not much but there is a small win here for braces. – Winston Ewert Apr 9 '11 at 21:40
  • @Winston - must be your editor. If the code you paste is in itself correctly indentet, then if it comes out a few levels too far to the right/left it's only a matter of typing (SHIFT+)Tab to align it accordingly - not real a difference to hitting the key to reindent the file. Besides - thou shalst not copy/paste code :) – Ingo Apr 10 '11 at 0:37
  • 1
    @Winston: even Notepad++ indent blocks when using Tab and Shift-Tab, I haven't yet found the vim short-cut, but I don't use it enough I guess :p – Matthieu M. Apr 10 '11 at 12:26

I love Python's significant whitespace. To me it's the perfect example of DRY at a syntactic level. The human-readable way to indicate where a block of code begins and ends is with indentation. If you want your code to be readable, you have to indent it regardless of language. It's silly to make the programmer specify this information twice, once for the compiler/interpreter and once for humans. Furthermore, indentation in C-like languages is similar to a comment: It's intended to improve understandability but its meaning is not enforced by the compiler/interpreter and it can get out of sync with the real meaning (where the braces are) very easily, obfuscating rather than clarifying.

  • 8
    +1 for Don't Repeat Yourself. Good practice is to indent the code to reflect block structure anyway, so why have begin/end markers as well? – Steve314 Jul 12 '11 at 2:43

Significant whitespace is actually convenient for me. It makes me type less. It formats code neatly and rather unambiguously. Due to this, it makes code more readable.

(I like significant whitespace in Haskell too, for the same reasons.)

  • 1
    I would have shared my positive experience with Haskell whitespace too, but FarmBoy insisted that one must have 3 months experience with Python, anything else was speculation. :-) – Ingo Apr 9 '11 at 22:51
  • 1
    My experience with Python us since 1998, so my answer probably qualifies :) (Too bad my experience with Haskell is far shorter.) – 9000 Apr 10 '11 at 12:06
  • @9000 Even though Haskell came before Python! :D – pradyunsg Feb 5 '14 at 10:36

When I first used python, the whitespace thing was new and therefore an annoying restriction.

Now I don't even notice it. I have been using python for 11 months.


First off - my bread and butter languages are Python, SQL, and Java. I love Python's whitespace - it's less syntax and typing, and it forces people to write legible, neatly formatted code. OTOH, I hate the verbosity of Java - so much so that I actually use Python to generate all the boilerplate I have to write in Java, which impresses all my Java coworkers who are amazed at my productivity.

The one big caveat, though, is when copy/pasting code from the web - it often causes mixed spaces and tabs which requires an extra step to clean up, and I usually only catch after a runtime exception.

  • Telling your editor to syntax highlight tabs as errors can help a lot - for vim I use highlight link RedundantSpaces Error | au BufEnter,BufRead * match RedundantSpaces "\t" | au BufEnter,BufRead * match RedundantSpaces "[[:space:]]\+$" in my vimrc – Daenyth May 22 '12 at 13:20

If a programmer are annoyed by the significance of white-spaces he probably won't become a python programmer.

  • 1
    I've heard quite a few people preaching Python that say they had their problems with The Whitespace Thing(tm) but came to like it after a while. From my observation, it seems that as more people join a a discussion on this topic, the propability of one of them telling such a story approaches one. (Edit: Immediately proven by the second answer...) – user7043 Apr 9 '11 at 21:11
  • @delnan, I can subscribe to this. – Ingo Apr 10 '11 at 1:04

I'd bet you would find considerable overlap between the people who have a problem with significant whitespace and those who do not have experience with a good programmer's text editor, such as Emacs, that handles most indentation without their involvement.

In any case, once you've internalized Python, it's not a problem any more; in fact, its conciseness and the small space it takes on the screen become a great advantage to readability. Since I've been using primarily Python, I find languages where there is more redundancy (e.g. Java and C#) difficult to discipline myself to write. Putting braces around code whose indentation already makes its structure clear grates on my nerves.


For actual coding, it isn't inconvenient at all, but actually beneficial (see dsimcha's answer).

It can be annoying when dealing with communications technologies that don't respect leading whitespace (such as many non-programming oriented web forums and also when embedding Python code inside a different language, such as HTML templating languages), Even though I see that as more of a defect in the tools that strip leading whitespace than a defect in Python, it is true that the redundant languages that express code structure twice are better equipped to handle such destructive environments (since you can paste the code into an editor and auto-reindent based on the explicit structural markers, or simply not care if the code is only being executed rather than read by humans).


I don't find the whitespace annoying. I find lack of or inconsistent indenting very annoying in other languages. I understand this problem is one of the problems that the style is intended to solve.

Python is not one of my primary languages.

I do find the handling of tabs and spaces in indentation annoying on occasion. This can cause problems when switching editors from one edit to another, or when editing code someone else wrote. It is usually trivial to resolve.

  • 1
    mixing tabs and space in python indentation is the shortest road to hell :p – Matthieu M. Apr 10 '11 at 12:28
  • @Mattieu: Definitely, that's my annoyance. – BillThor Apr 10 '11 at 16:50

I come from a C# / Javascript / XBase background in no particular order, and in my dabblings with Python it is not a consideration at all for me. It's like braces in other languages - that's how it works, put the things in like the rules say, and dry your eyes is my attitude.

Not the answer you're looking for? Browse other questions tagged or ask your own question.