[Python-ideas] Making colons optional?
ben+python at benfinney.id.au
Thu Feb 5 05:07:36 CET 2009
Riobard Zhan <yaogzhan at gmail.com> writes:
> - I noticed a strong tendency to forget colons by new users of
I've also noticed this, but I also notice that it doesn't take long at
all (on the order of hours) for the new user to get used to the
> - We already have indentation to visually separate different levels
> of code. Why bother with those extra colons at all?
Because indentation also occurs for other reasons, a major example
being continuations of previous lines.
for line in foo:
That's three lines at differing indentation levels, but two
I find that the line-end colon is a strong visual indicator that a
suite is being introduced, as contrasted with some other difference in
> - Do you find yourself sometimes forget to type them and the
> interpreter complains?
Not since a few days learning the language, no.
> - Are the above pieces of code less readable due to lack of colons?
The examples you've chosen, no; but I think that a lot of code which
uses multi-line statements with implicit continuation would be made
less readable without colons to indicate the introduction of suites.
\ “I hate it when my foot falls asleep during the day, because |
`\ that means it's gonna be up all night.” —Steven Wright |
More information about the Python-ideas