2023-09-05 18:26 UTC+02:00, Dom Grigonis <[email protected]>:
> I like the idea of eliminating it if it was possible. This is one of my most
> common syntax errors (although mostly after function signature) and I am not
> C/C++ programmer. I am not sure about the core technical issues, but
> readability of code, such as:
> a = 1
> while a < 5: a += 1
> , would suffer:
> a = 1
> while a < 5 a += 1
> So IMO, it does improve readability in certain cases.
>
> Although, removing colon does sound like an idea worth thinking about. I
> might even dare to suggest disallowing body statement on the same line, but
> can’t do that for backwards compatibility ofc...
>
> So my point is, if anyone is going to give a thought about this, please add
> function signature to the list.
>
I just want to mention that without colons, one-liners could become ambiguous:
while a < b (x := c) - 42
Is it:
while a < b:
(x := c) - 42
Or:
while a < b(x := c):
-42
Or:
while a < b(x := c) - 42:
# ???
If anything, the colon would become optional but would definitely
remain in the grammar. Kinda like the semi-colon, only used in
one-liners.
When teaching python I noticed the usual uselessness of the colon
regarding the correct parsing of correctly indented code.
But I've never seen it as a burden and rarely if ever forgot one. It
also allows code editors to be very simple: you see a line ending with
a colon, you indent the next line. The keyword at the begining of the
line doesn't matter.
Best regards,
Celelibi
_______________________________________________
Python-ideas mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at
https://mail.python.org/archives/list/[email protected]/message/UL3FSZWUKOVUASIPM46IPQIQPJ7GEV7Q/
Code of Conduct: http://python.org/psf/codeofconduct/