3 ms·
Well, the best option would be to have := (or any other operator) as C style assignment in the first place. This is huge backward compatibility breakage though
by bluecalm 8y ago
Well, the best option would be to have := (or any other operator) as C style assignment in the first place. This is huge backward compatibility breakage though so the second best option is to use =.
You can require additional brackets around assignment if you use the returning value (or otherwise it's syntax error). They did that with the new one anyway.
- thomasahle 8y ago> You can require additional brackets around assignment if you use the returning value (or otherwise it's syntax error). They did that with the new one anyway. They only did it if the := is at the root level. The following is completely legal: if match := re.search(pat, text): `print("Found:", match.group(0)) or [y := f(x), y**2, y**3]
- bluecalm 8y agoGreat, I haven't used := thing yet. I think it's more elegant like that.