Reply to post: Re: Reinventing a more limited wheel

Python creator Guido van Rossum sys.exit()s as language overlord

Flocke Kroes Silver badge

Re: Reinventing a more limited wheel

No because this is not about comma lists, which have very context dependent meanings in both languages. It is not about the comma operator, which in C means calculate the left argument for side effects and return the right argument (in python, the , operator creates a tuple of the two or more arguments). This is about expressions, statements and assignments. Both languages have contexts where an expression is permitted but not a statement, for example C: "while(expression) statement or {statement list}" and python: "while expression: statement or indented block". The difference was that in C assignments are expressions but in python assignments had to be statements. (Both languages allow using an expression where a statement is expected).

The new feature in python is an extra assignment operator (:=) so assignment expressions are now possible. In the past, converting C: "if (a=b) {...}" to python required the assignment to be in a separate statement from the condition making it abundantly clear that the programmer did not intend C: "if (a==b) {...}". Python will now allow: "if (a:=b): ..."

This has clearly caused a blood feud between different styles of language designers. On one hand, some people think that best practices must be forced down the throat of all programmers because some of them have to create insane code when the language allows it. Other people think that programmers that dumb are going to fuck up no matter what the language enforces, so the language should rely on the sensible programmers' self discipline to follow best practices and not get in the way when a programmer has an outstanding reason to do something odd.

Before you reply that clearly python has lacked C's assignment operator for years, there are plenty of things that C++ has attempted to copy from python (or whatever language python copied from), and often still struggles to get close to tolerable.

POST COMMENT House rules

Not a member of The Register? Create a new account here.

  • Enter your comment

  • Add an icon

Anonymous cowards cannot choose their icon

Biting the hand that feeds IT © 1998–2019