Python 3.8 Adds Walrus Operator, Improves Developer Experience

The new release of the popular programming language includes capabilities to help developers produce better code, but it might take a while for enterprise adoption.

Sean Michael Kerner, Contributor

October 30, 2019

3 Min Read
Python progamming language
Getty Images

The open source Python programming language sits at the top of multiple lists, including one from the IEEE, as the most popular language for developers.

Among the reasons for its popularity are its modularity and its steady pace of innovation. Now developers have even more reasons to use Python, thanks to the updates in the latest 3.8.0 release that became generally available on Oct. 14.

One of the biggest highlights of Python 3.8.0 is a new feature for assignment expressions known as the Walrus Operator.

"There is new syntax := that assigns values to variables as part of a larger expression," the Python 3.8.0 release notes state. "It is affectionately known as 'the walrus operator' due to its resemblance to the eyes and tusks of a walrus."

As an open source effort, the core Python language is freely available to anyone who wants to download it, and the language also benefits from multiple vendors that provide commercial support, including Vancouver-based ActiveState Software. Jeff Rouse, vice president of product at ActiveState, told ITPro Today that the Walrus Operator can be used to reduce the size of programming loops.

All Python features start off as a Python Enhancement Proposal (PEP), and that was the case with the Walrus Operator, also known as PEP 572.

"When the PEP was first proposed, it got a lot of flak for being open to abuse," Rouse said. "I think that's the case for many of Python's features."

Python is wonderfully flexible, according to Rouse, but that means that people can do bad things. In the case of the Walrus Operator, Python does a great job of making code easier to follow when used in the right circumstances, he said.

Debugging Syntax

Python 3.8 also benefits from some incremental debugging improvements. Among them is support for new syntax in Python's f-string.

"Added an = specifier to f-strings," the release notes state. "An f-string such as f'{expr=}'will expand to the text of the expression, an equal sign, then the representation of the evaluated expression."

Rouse said users of MyPy, which is a static type checker for Python, will likely be very excited about the new "TypedDict" class (PEP-589).

"It's now much easier to represent both a strict structure of a dictionary as well as the types of each key," he said.

Security

Release 3.8 of Python also boasts security improvements, including Audit Hooks (PEP-578), which can be used to provide runtime control for code.

"It will give users a lot more control over what Python is and isn't allowed to do," Rouse said.

Python 3.8 is available now; however, Rouse doesn't expect broad adoption by enterprise developers quite yet. Of course, there are developers who adopt new Python releases quickly, he said, and that's something that ActiveState sees in the data for its community edition downloads.

"Like most products, you get the leading-edge developers who want to use the new capabilities right away, but the vast majority are two to six months after launch and then the enterprise crowd comes along much later, often six to 18 months later, and some won’t upgrade until a version is going to reach an end of updates," Rouse said. "Enterprises generally don’t respond to new capabilities unless it is a game-changer for their particular needs; they are much more concerned about stability and risk.

"We also don’t recommend that our business customers move to the first version of a new minor release like 3.8, [but] wait until you get the first set of updates in 3.8.1 and it becomes more battle-tested."

About the Author

Sean Michael Kerner

Contributor

Sean Michael Kerner is an IT consultant, technology enthusiast and tinkerer. He consults to industry and media organizations on technology issues.

https://www.linkedin.com/in/seanmkerner/

Sign up for the ITPro Today newsletter
Stay on top of the IT universe with commentary, news analysis, how-to's, and tips delivered to your inbox daily.

You May Also Like