Py3K idea: why not drop the colon?

skip at pobox.com skip at pobox.com
Fri Nov 10 14:31:13 EST 2006


Replying via Steve's not to (I think) a comment from Michael Hobbs
(apologies to Steve):

    >> The FAQ says that the colon increases readability, but I'm
    >> skeptical. The indentation seems to provide more than enough of a
    >> visual clue as to where the if conditional ends.

I use four-space indents whenever possible.  If I have a multi-line
condition I find that the condition indents to the same level as the the
indented block, e.g.:

    # Oh, wait, I shouldn't have typed that colon just now!  It's not
    # necessary.  Oh, darn.  Hmmm... What does Strunk say?
    if (some_long_expression and
        some_other_long_expression and
        yet_another_long_expression):
        that_was_a_long_expression = True

I don't know if this is just a shortcoming of the style I use to break lines
in a long expression or what, but the colon makes it clear where the
condition ends and the indented block begins.

Skip



More information about the Python-list mailing list