Python Indentation

So, one of the touted benefits of Python is its indentation-based structure. Who needs curly braces, begin-end blocks, or (heaven forfend) parentheses? Now, I agree … proper indentation makes reading code easier. However I don\’t indent my code, my editor does. And when I change the structure of something one keystroke fixes all the indentation. Does this happen in Python editors? How does it know which parts should be re-indented, and which are correct? Does the programmer walk line-by-line typing tab, or is the editor really smart enough to handle it?

Haskell behaves the same way as Python, but

  1. I don\’t write much Haskell either and
  2. the code I do write doesn\’t really have much indentation, thanks to pattern matching.

I\’ll admit — I\’m pretty hooked on parentheses. Working with an AST directly feels so powerful, and reader macros allow me to add syntax where necessary. I will try to listen to the Python side, though. I was pretty into the idea of indentation-based structure for a while.

BTW, this comes to mind because of Guido\’s posting where he says, \”I find any solution unacceptable that embeds an indentation-based block in the middle of an expression,\” which sounds more like an indictment of indentation-syntax than of lambdas.

Comments are closed.