Riobard Zhan <yaogzhan@gmail.com> writes:
- I noticed a strong tendency to forget colons by new users of Python
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 requirement.
- 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: do_something( spam, line) That's three lines at differing indentation levels, but two statements. 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 indentation.
- 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 | _o__) | Ben Finney