Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Python 3.8 :=
#1
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
Reply


Messages In This Thread
Python 3.8 := - by jgitlin - Dec-22-2019, 01:16 AM
RE: Python 3.8 := - by ichabod801 - Dec-22-2019, 02:02 AM
RE: Python 3.8 := - by perfringo - Dec-22-2019, 07:52 AM
RE: Python 3.8 := - by jgitlin - Dec-22-2019, 01:51 PM
RE: Python 3.8 := - by ichabod801 - Dec-22-2019, 03:03 PM

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020