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. — One small step towards deferred evaluation, one huge leap for… — Dg > On 1 Sep 2023, at 13:26, Morteza Mirzakhan <morteza.mirzak...@gmail.com> > wrote: > > Dear Python Developers, > > I would like to share my thoughts on the use of the colon mark “:” in Python > code. > > In my opinion, using a colon after keywords such as `if`, `elif`, `else`, > `for`, `while`, `try`, `except`, and `finally` is quite unnecessary. > > Using mandatory indentation in Python to group commands into a block is > similar to how curly braces `{}` are used in ‘curly-bracket languages’ like > C-family, Perl, Java, PHP, etc. to group multiple commands into a single > statement. > > While those compilers don't differentiate between one or more ‘space’ or > ‘return’ characters, so they don't recognize new lines and indents, the > indentation is also used, not forced but traditionally, to increase > readability. However, when it comes to writing just one instruction after the > head command, you can omit the curly braces `{}` and simply write it in a new > line, traditionally indented in C-family languages. > > So Python is one step forward by not requiring curly braces `{}` whether the > block includes one or more lines. > > In contrast, the requirement to use a colon after those keywords in Python is > a drawback! > > The colon “:” doesn't improve readability but adds unnecessary complexity, > increases the potential for errors, and requires more effort to code. This is > because the requirement does not have a logical meaning while the block is > made obvious by indentation, so coders may forget to include the colon and > face errors. > > This can be particularly frustrating for those who are used to coding in > languages such as C and C++, where blocks of code are traditionally indented > and no curly braces `{}` are used when the following tail is a singe-command > instruction. > > The suggestion is removing the need by interpreter for the use of colon after > keyword syntaxes (and making it optional due to Backward Compatibility) in > the new revision of Python. > > I believe this change would make Python code easier to read, less prone to > errors, and require less effort to code. > > Thank you for your time and attention. > > Best regards, > Morteza Mirzakhan > _______________________________________________ > Python-ideas mailing list -- python-ideas@python.org > To unsubscribe send an email to python-ideas-le...@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/E7LCNY6LBWQ5HHI6BHWRDXFE2MMIBZCC/ > Code of Conduct: http://python.org/psf/codeofconduct/
_______________________________________________ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-le...@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/TH2SHGK6FIVBPUSWCUW42VMWNDEOLLTR/ Code of Conduct: http://python.org/psf/codeofconduct/