Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Python 3.8 :=
#4
Hello there. I think I was given inaccurate answers.

I know that
:= does not work in Python 3.7!
My question dealt with a new Python feature.

Python 3.8, released in October of this year introduced :=

Please read from "What's New":
Summary – Release highlights
New Features
Assignment expressions
There is new syntax := that assigns values to variables as part of a larger expression. It is affectionately known as “the walrus operator” due to its resemblance to the eyes and tusks of a walrus.

In this example, the assignment expression helps avoid calling len() twice:

if (n := len(a)) > 10:
print(f"List is too long ({n} elements, expected <= 10)")

...
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