Since Python 3.8 allows one to combine assignment with a condition like:
if (x:=f()) == 1:
print("function returned 1")
Is there any reason in Python 3.8 or greater, to use assignment with =. I think that we should always use := in new code.
Most of you know that the following is valid in Java and C/C++ if ( ((x=f()) == 1)
And Algol used := for assignment to make sure that no one confused assignment and test for equality
if (x:=f()) == 1:
print("function returned 1")
Is there any reason in Python 3.8 or greater, to use assignment with =. I think that we should always use := in new code.
Most of you know that the following is valid in Java and C/C++ if ( ((x=f()) == 1)
And Algol used := for assignment to make sure that no one confused assignment and test for equality