Top 10 cool new features in python 3.8
- May 2, 2020
- Posted by: Coursack
- Category: python
The cool new featured version of Python 3.8 has released! Now, we will all start twiddling with the new features and enjoy the newest improvements. Let’s see the new features in python 3.8
The Walrus within the Room: Assignment Expressions
The biggest change in Python 3.8 feature is that the introduction of assignment expressions. They’re written employing a new notation (:=). This operator is usually called the walrus operator because it resembles the eyes and tusks of a walrus on its side. Assignment expressions allow you to assign and return a worth within the same expression.
The built-in function float() are often used for converting text strings and numbers to float objects. At a glance, arguments can seem a touch limiting and contrary to Python’s mantra about the importance of readability. You’ll find that there aren’t tons of occasions where arguments improve your code.
What are the new features in Python 3.8?
But, within the right circumstances, arguments can offer you some flexibility when you’re designing functions. First, arguments add up once you have arguments that have a universe but are hard to offer good, descriptive names to.
Another possible advantage of using arguments is that you can more refactor your functions. Especially, you’ll change the name of your parameters without fear that other code depends on those names.
More Precise Types
Python’s typing system mature at now. But, in Python 3.8, some new features added to typing to permit more precise typing:
- Literal types
- Typed dictionaries
- Final objects
Simpler Debugging With f-Strings
F-strings was first introduced in Python 3.6, and became very fashionable. They could be the foremost common reason for Python libraries only supports on version 3.6 and later. An f-string may be a formatted string literal. You’ll recognize it by the leading f. once you use f-strings, you’ll enclose variables and even expressions inside curly braces. They’re going to then evaluated at runtime and included within the string. In Python 3.8, you’ll use assignment expressions inside f-strings.
The Python Steering Council
Python’s governance isn’t a language feature. But, Python 3.8 new feature is that the first version of Python not developed under the benevolent dictatorship of Guido van Rossum. The Python language is now governed by a steering council consisting of 5 core developers:
- Barry Warsaw
- Brett Cannon
- Carol Willing
- Guido van Rossum
- Nick Coghlan
The road to the new governance model for Python was a stimulating study in self-organization. Guido van Rossum created Python within the early 1990s, and has been a dubbed Python’s Benevolent Dictator for all times (BDFL).
Other Pretty Cool Features in Python 3.8
So far, you’ve seen the most important headline news about the cool features on what’s new in Python 3.8. But, there are many other changes that also are pretty cool. During this section, you’ll get a fast check out them.
There is one new module available within the standard library in Python 3.8: importlib.metadata. Through this module, you’ll access information about installed packages in your Python installation. Along-side its companion module, importlib.resources, importlib.metadata improves on the functionality of the older
New and Improved math and statistics Functions
Python 3.8 new features brings many improvement modules of .math within the standard library features a few new functions math.prod() works to the built-in sum().
The two statements are equal prod() are going to be easier to use once you have already got the factors stored in an iterable.
The statistics module also has several new functions:
- statistics.fmean() calculates the mean of float numbers.
- statistics.geometric_mean() calculates the mean of float numbers.
- statistics.multimode() finds the foremost occurring values during a sequence.
Warnings about Dangerous Syntax
Python features a Syntax Warning which may warn about dubious syntax that’s not a SyntaxError. Python 3.8 adds a couple of new ones which will assist you during coding and debugging.
The difference between is and == are often confusing. The latter checks for equal values, while it is True only objects are an equal. Python 3.8 will attempt to warn you about cases once you should use == rather than ‘is’
It’s easy to miss a comma when you’re writing out an extended list, especially when formatting it. Python 3.8 additionally emits a warning that points toward the important issue:
There are several optimizations made for Python 3.8. Some that makes code run faster. Others reduce the memory footprint. For instance, looking up fields during a named tuple is faster in Python 3.8 compared with Python 3.7 You should have only a few issues running Python 3.7 code in Python 3.8. Upgrading your environment to run Python 3.8 is thus quite safe, and you’d be ready to cash in of the optimizations made within the remake.