Github ranked Python to be #2 most popular programming language in 2019. It is praised for being concise, easy to learn and use, rich in features. In addition, Python and R are to-go languages for data science applications. Python 3.8 was released in October of 2019 and here are the new exciting features that came with it:
PEP 572 – Assignment Expressions
The new “walrus operator” that looks like this: :=
, allows you to assign a value and return it within the same statement. This can be useful in some cases and reduce the complexity and number of lines. Here is an example:
PEP 570 – Python Positional-Only Parameters
PEP 570 introduced the /
symbol, which marks a parameter as positional-only in the function declaration. Now you can decide which parameters can be passed only with a keyword, only without a keyword or both. Check this out:
Easier debugging with f-strings
String interpolation simplified a lot of things for Python developers. But developers can always think of a way to simplify further. Now, f-strings support a new syntax that lets you output a variable name alongside that variable content. Here is how it works:here are the new exciting features that came with it:String interpolation simplified a lot of things for Python developers. But developers can always think of a way to simplify further. Now, f-strings support a new syntax that lets you output a variable name alongside that variable content. Here is how it works:
Other improvements
These are the main areas that developers will likely notice. In addition, there are more subtle changes. For instance, the multiprocessing module now supports sharing memory segments across processes. This improves performance as you no longer have to serialize data for inter-process communication. In addition, you can now use continue
instruction in finally:
blocks.
You can download the new version from python.org. Note for macOS users: Python 3.8 only supports 64-bit systems and macOS 10.9+.