What’s New in Python 3.8? – Python Guide for Beginners

0
30

So, Python 3.8 has been around a while now, October 14th, 2019 to be accurate. But it is still not used across the board because most people don’t know about the feature-set it brings to the table.

Some of the contemporary features are as follows:

• The Walrus Operator (:=)
It’s called so because the operator symbol resembles a “walrus”.This operator is used to assign and return a value in the same expression. Generally the assignment and retrieval of a value took two statements, but python 3.8 has made it more convenient.

Lets look a few examples:

Simple Print:-

3.7

3.8

While Loops:-

3.7
3.8

• Simpler use of F strings
It is basically used for string replacement as can seen in the given example:

New:-

In Python 3.8, you can use assignment operators.

New Specifier:

Using this specifier , you can print both the text as well as the value of the variable using only this simple syntax.

You can also add spaces after ‘=’ and use the format specifier.

• New Module importlib.metadata

Through this module, you can access information about installed packages in your pc on python.

• Positional Only Arguments
New parameter syntax ‘/’ is used . It is used to specify that some parameters must be specified positionally according to function needs.

Here more than required positional arguments were given.

Here only ‘name’ is a positional only argument while ‘greet’ is a regular argument that is why in the third iteration the output gives an error.

• New Statistics Functions
Prod function -used to simply multiply numbers.

isqrt function- used to find only the integral value of a square root.

No modulus operator need be used.

Dist function- used to find the distance between the two points

Hypot function – used to find the length of a vector

statistics.fmean()– used to find the mean of float numbers

statistics.geometric_mean()- used to find the geometric mean of float numbers

statistics.multimode()- used to find most frequently occurring values

statistics.quantiles()- used to cut points for dividing data into n continuous intervals with equal probability.

• ‘Finally’ and ‘Continue’ statements
In python 3.7 , you cannot use the ‘continue’ keyword in a ‘finally’ clause, as shown below:

But now in the new version it is supported, the same code in the new shell:

• New Optimizations
Some new optimizations to reduce ‘run’ timings and reduce memory usage.

Saving memory on initializing lists.

3.7

3.8

So, the real question is “Should you upgrade to version 3.8?”

Well , if you want to try out the new features you should absolutely upgrade to it.

About moving your projects from ver- 3.7 to ver- 3.8, Django and anaconda have both made it easy to switch between multiple versions. So switch as you like.

Ultimately it comes to you , if you think you can utilize the interesting but subtle features , try it out . Otherwise Python version 3.6 has become the base and most libraries and packages can be used on it without much problem.

END

These were some of the many features of this new version that I thought were easy to understand & interesting enough to share. For more detailed information check the python official web site:

https://docs.python.org/3/whatsnew/3.8.html