Since the switch to Python 3 a long time ago (ahem — I hope it was a long time ago!), the feature changes at the language level have been relatively minor. Yet with each version, the brainiacs working on Python keep making additions I am unable to live without.

With Python 3.8 released in October 2019, I find myself using features of the language that when I first read about them, made me say “whatever.”

  • 3.5 — type annotations
  • 3.6 — asyncio
  • 3.7 — dataclasses
  • 3.8 — assignment expressions aka walrus operator

And in 3.9, dictionary union operators and generic type hints. Trying to keep the exclamation points to a minimum, but this is exciting stuff!

All the above, I use all the time in code bases professionally, and in my projects for fun.

Quick soapbox speech: If you are still on older versions of Python for work or in your projects, don’t be afraid to upgrade! Your old code will still work, plus you will get the benefits of Python’s new features!

Disclaimer: This is untrue if you’re still using Python 2.7. But in that case, you’re not the type to take good advice anyway. 😎

Below I will go over (quickly) some of my favorite features I hope you will find using in your coding every day.

Those are: type annotations, dataclasses, dictionary union operator, the walrus operator.

In this part: type annotations, the walrus operator.

Typing — 3.5+

Typing has been a feature worked on since the start of Python 3. Since we’re developers, not historians, here will be type annotations and type hints as they stand now (2020).

Python does not need types assigned to variables. That’s probably part of the reason I love the language so much. The clean, readable syntax. The ability to code a solution one of two dozen different ways and still get the same result.

But then… the application grows. Or you have to look at code you haven’t touched in months or years. Or, worst of all, you have to understand code written by someone else! shudders

#software #python #2020 #python3 #python-programming

What’s New in Python 2020 — Part 1
3.55 GEEK