What's New in Python 3.8? - Python Guide for Beginners Skip to content

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

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

Python 3.8

3.8

Python 3.8

While Loops:-

3.7

python 3.8
python 3.8

3.8

python 3.8
python 3.8

• Simpler use of F strings

It is basically used for string replacement as can seen in the given example:

python 3.8

New:-

In Python 3.8 , you can use assignment operators.

python 3.8

New Specifier:

python 3.8

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.

python 3.8

• New Module importlib.metadata

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

python 3.8
python 3.8

• Positional Only Arguments

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

python 3.8
python 3.8

Here more than required positional arguments were given.

python 3.8

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.

python 3.8

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

No modulus operator need be used.

python 3.8

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

python 3.8

Hypot function – used to find the length of a vector

python 3.8

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.

python 3.8

• ‘Finally’ and ‘Continue’ statements

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

python 3.8

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

python 3.8

• New Optimizations

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

Saving memory on initializing lists.

3.7

python 3.8

3.8

python 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

Sign Up and Start Learning