What does Python fix?

François Pinard pinard at iro.umontreal.ca
Thu Jan 17 18:30:04 EST 2002

[Joseph A Knapka]

> Someone should write a Lisp system that uses indentation a la Python
> instead of parens.  That would rock.  Especially if it compiled to Python
> bytecode and could use the entire Python library.  Hmm....  I guess the
> result might be called "Python."

I read your remark as half humorous, half serious.  Let me reply to the
serious part of it, because it is worth a thought.

Python, roughly summarised, has statements and expressions.  Indentation is
used for statements only.  As for expressions, Python is similar to LISP,
in that indentation has no meaning, and parentheses are often necessary.
We do agree that priority rules for operators alleviate the need of many
parentheses in Python.

LISP has nothing but expressions, or at least, theoretically.  In practice,
people have a feeling of writing LISP statements, but the distinction is
fully subjective, a bit fuzzy, and not necessary.  For being able to use
indentation to replace parentheses, this distinction would probably need
to be formalised and made unbearably rigid.

Also remember that LISP allows arbitrarily complex expressions to be used
in all positions of a function call, that is, for any argument or for the
function itself.  I do not see how one could unambiguously express such
things through pure indentation.  By comparison, Python needs verbosity to
render such intents.  Even if it was possible to purely rely on indentation,
the code would use a lot more vertical space, as the current LISP notation
is rather compact.  This bloat will not be welcome.

François Pinard   http://www.iro.umontreal.ca/~pinard

More information about the Python-list mailing list