An interesting beginner question: why we need colon at all in the python language?

Thomas Jollans t at jollybox.de
Mon Jul 11 11:01:58 EDT 2011


On 07/11/2011 04:36 PM, Dave Angel wrote:
> The character you're asking about is the colon.  It goes at the end of
> an if, else, for, with, while statement.  I doubt it's absolutely
> essential, but it helps readability, since a conditional expression
> might span multiple lines.
>         if someexpression ==
>               someotherexpression:
>             body_of_the_conditional

That, of course, is not legal Python. Your point stands when you add
brackets or a backslash to hold the condition together.



More information about the Python-list mailing list