←back to thread

2024 points randlet | 6 comments | | HN request time: 2.211s | source | bottom
1. password4321 ◴[] No.17515875[source]
>Now that PEP 572 is done, I don't ever want to have to fight so hard for a PEP and find that so many people despise my decisions.

PEP 572: Python assignment expressions has been accepted

https://news.ycombinator.com/item?id=17448439

replies(2): >>17518581 #>>17520692 #
2. ehsankia ◴[] No.17518581[source]
Is the final syntax := surrounded by parenthesis?
replies(1): >>17518604 #
3. hermitdev ◴[] No.17518604[source]
Yes
replies(1): >>17519854 #
4. int_19h ◴[] No.17519854{3}[source]
If the PEP that's published is final, then it only requires parens in certain context to make things clearer, like on the right side of the assignment statement.
5. skywhopper ◴[] No.17520692[source]
Yeesh, that’s a sad thing to burn out over. Python made this decision to avoid assignment expressions a long time ago and has done fine without this capability. Why not just leave well enough alone? Adding a new variation to assignment syntax (just because of the opinion that = vs == is too confusing (even though C and Ruby and many other languages deal with it fine)) is just going to add more confusion to the language. For a line saved here and there?
replies(1): >>17531699 #
6. cben ◴[] No.17531699[source]
I had the same gut reaction when I heard the PEP even exists. But now I actually read the PEP, it's very well written and makes a reasonably good case that in specific scenarios it will be an improvement.

(My second gut reaction was it should have used `as NAME` postfix syntax. The PEP debunks that too. Turns out it previously proposed that and the switch to := was a major improvement :-)

The bigger question is whether the gains justify making the language larger... That's subjective, impossible to settle by debate, and the kind of thing a BDFL can help decide one way or the other :-)