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/

Reply via email to