3 ms·
This is a bit like something you can do in C, almost by accident as a bonus language feature. x = y = z = 4; But I think this is assignment expressions whic
by ramshorns 6y ago
This is a bit like something you can do in C, almost by accident as a bonus language feature.
x = y = z = 4;
But I think this is assignment expressions which were controversial in Python or something.
- mark-r 6y agoNot anymore, check out the walrus operator.
- sk0g 6y agoYeah in Python you can do, say, a = b = [] But then the two lists are the same, and appending to one appends to the other. Not particularly useful.
- Ragib_Zaman 6y agoIt's useful when the object being assigned to those variables are literals instead of reference types, which in my experience is most of the time when you want to do the simultaneous assignment. When you do want to do reference types, you can do a,b = [], [].