The colon remains syntactically necessary in some cases, particularly to disambiguate cases involving one-lining (no block involved). Stupid example: If the colon is optional, what does:

if d +d

mean? Is it a test of the value of d, followed by invoking the unary plus operator as a one-liner (that is, was it "if d: +d")? Or is it testing d + d, and opening a block on the next line ("if d + d:")?

On Thu, Jan 16, 2020 at 6:15 PM Random832 <random832@fastmail.com> wrote:
On Tue, Jan 14, 2020, at 18:15, David Mertz wrote:
> For what it's worth, after 20+ years of using Python, forgetting the
> colon for blocks remains the most common error I make by a fairly wide
> margin. Of course, once I see the error message—even being not all that
> descriptive of the real issue—I immediately know what to fix too.

What if the colon were made optional, with an eye to perhaps eventually no longer using it as the preferred style for new code?

We had a post a while ago about the possibility of using the lack of a colon as an implicit line continuation (like with parentheses, e.g. "if a\nand b:", and this was (reasonably) rejected. But if a line beginning as a compound statement and ending without a colon is *never* going to have a valid meaning as something else... what's the point of the colon, otherwise? Seems like just grit on the screen.
_______________________________________________
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-leave@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at https://mail.python.org/archives/list/python-ideas@python.org/message/J47TEY2KFGATFMQ7RSZJO7B4RV7KEYWJ/
Code of Conduct: http://python.org/psf/codeofconduct/