Assignment expressions: Noooo!

微信扫一扫,分享到朋友圈

Assignment expressions: Noooo!

I just got wind of PEP 572
via Reddit.The PEP is to modify the Python syntax to add an assignment expression via the use of := to both assign a value to a name, and create a value for the assignment of the the assigned value.

So:

y = 0 
x = (y :=2*3)*(y := y**2)
s, t = y:=x + 1, x := y + 1

Would presumably be valid syntax.

I feel strongly that this is a bad idea and wrote a reddit reply
copied here to show my disfavour:

Please tell me this PEP is a joke!

After GvR stating the removal of assignment within expressions as one of the canonical ways of making Python easier to read and maintain; this PEP is a slap in the face.



I believe that Python is
better without it. If a name can be both assigned to and used, in the same expression then rules of precedence need creating and teaching. This was problematic in the C language.


I wonder if this is a case of people wanting to help, and searching for something they can help with. Their thought being “other languages have it so it would help when translating algorithms from other languages”.


Unfortunately, this. PEP 572 would add in to Python another C language maintenance nightmare feature with little benefit.


We have to beware the accretion of features for features sake in Python. I applauded the bold changes needed in forming Python3, and feel there needs to be restraint in shoving aside something that has made Python so readable for so long.

微信扫一扫,分享到朋友圈

Assignment expressions: Noooo!

You Have No Control Over Your Data, Even Your DNA

上一篇

Sprint and T-Mobile agree to all-stock merger deal worth $26 billion

下一篇

你也可能喜欢

Assignment expressions: Noooo!

长按储存图像,分享给朋友