[Python-ideas] Making colons optional?

Riobard Zhan yaogzhan at gmail.com
Thu Feb 5 17:05:17 CET 2009


On 5-Feb-09, at 12:37 AM, Ben Finney wrote:
>
>> - 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.

Actually this is the first concrete example for colons. Thanks very  
much for bringing it up, Ben! :)

Here is a counter-example for the strong visual indicator cause.

     for some_list in some_collection:
         do_something(some_list[1:
], something_else)





More information about the Python-ideas mailing list