[Python-3000] PEP 3125 -- a modest proposal (original) (raw)

Raymond Hettinger python at rcn.com
Tue May 8 07:40:21 CEST 2007


[Andrew Koenig]

It has occurred to me that as Python stands today, an indent always begins with a colon. So in principle, we could define anything that looks like an indent but doesn't begin with a colon as a continuation. So the idea would be that you can continue a statement onto as many lines as you wish,

Too dangerous. The most common Python syntax error (by far, even for experienced users) is omission of a colon. If the missing colon starts to have its own special meaning, that would not be a good thing.

If you're in the mood to propose something radical, how about dropping the colon altogether, leaving indention as the sure reliable cue and cleaning-up the appearance of code in a new world where colons are also being used for annotation as well as slicing:

def f(x: xtype, y: type) result = [] for i, elem in enumerate(x) if elem < 0 result.append(y[:i]) else result.append(y[i:]) return result

It looks very clean to my eyes.

Raymond



More information about the Python-3000 mailing list