Demand for Online Learning Apps in 2024: A Comprehensive Guide
As we step into 2024, the demand for online learning apps is on the rise. There’s growing demand for E-learning apps and more and more people are willing to learn […]
High-level, general-purpose programming language Python emphasises code readability with the use of indentation. According to the TIOBE Index for October 2021, Python is the most popular programming language in the global developers’ community.
Python released its latest upgrade, Python 3.10, on October 04, 2021, soon after the 30th anniversary of the programming language. While there are several new features in the latest in-development version, the most significant upgrade has to be the language syntax, since async.
Python 3.10, the latest release of Python, is in its beta phase. This article explores the major changes and updates to the previous version.
Structural pattern matching has been added in the form of two statements — ‘match statement’ and ‘case statements’ of patterns with associated actions. Patterns for comparison can consist of sequences — lists and types; mapping structures — dictionaries; primitive data types or class instances. The syntax around the two statements — ‘match’ and ‘case’ expanded, can now be used to extract information from complex data types, branch the structure of data or apply other specific actions to varied data forms.
The generic syntax of pattern matching is as follows:
Thus, pattern matching operated by:
In previous versions of Python, debugging a code is pretty difficult due to poor error messages. Error messages generated by the Parser from previous versions of Python are not specific.
Consider the code below:
print(“Hello Reader”
print(“Welcome to The Chief IO”)
#The Error Message
File “<string>”, line 2
print(“Welcome to The Chief IO”)
^
SyntaxError: invalid syntax
The error message generated points that the error is in line 2, whereas the actual error is in line 1. This makes debugging hard.
Python 3.10 proposes a more accurate and line-precise error message, assisting you in figuring out where the problem is from.
For the same example above, Python 3.10 will generate the following error message which is clearer;
File “<string>”, line 1
print(“Hello Reader”)
^
SyntaxError: ‘(’ was never closed.
A new method, bit_count, is introduced in Python 3.10. This method will return the number of ones present in the binary representation of an integer.This method is also known as Population Count (popcount) and it gives you a faster way of counting non-zero bits in an integer.
Python 3.10 also comes with an improved type union checking syntax that will help you write cleaner codes. Instead of using typing.Union to compare two data types, python 3.10 enables you to use the or (|) operator with type annotations and also functions like isinstance() and issubclass().
Here is an example of the old syntax;
def func(value: Union[int, float]) -> Union[int, float]:
return value
With the new | operator, we can write the same code like this;
def func(value: int | float) -> int | float:
return value
Here is an example of the usage with isinstance() function;
isinstance(“hello”, int | str)
# True
A new optional Keyword argument, strict, is added to the zip function in Python 3.10. If you set the strict keyword to true, the iterables that you are zipping must be of equal lengths, or else, an error value will be raised.
Some earliest support for abstract base classes and old import semantics will be dropped from Python 3.10 onwards.
Some of the deprecated syntax includes find_loader()/find_module, load_module and _load_attribute.
Support for Distutils is also discontinued and replaced with setuptools and packaging.
OpenSSL 1.1.1 or newer is now required to build CPython. This modernizes one of CPython’s key dependencies (PEP 644).
Web DesignWebsite developmentWhat is New!What's Hot
Mar 19th, 2024
As we step into 2024, the demand for online learning apps is on the rise. There’s growing demand for E-learning apps and more and more people are willing to learn […]
Mar 14th, 2024
Taxi Booking App Development Company in Singapore
Feb 29th, 2024
Selecting the appropriate frontend framework is essential in the ever-changing world of web development if you want to create cutting-edge, responsive, and user-friendly online apps. It is important to go […]