What’s New In Python 3.9
New Features
Dictionary Merge & Update Operators
Merge (|) and update (|=) operators have been added to the built-in dict class. Those complement the existing dict.update and {**d1, **d2} methods of merging dictionaries.
New String Methods to Remove Prefixes and Suffixes
str.removeprefix(prefix) and str.removesuffix(suffix) have been added to easily remove an unneeded prefix or a suffix from a string. Corresponding bytes, bytearray, and collections.UserString methods have also been added. See PEP 616 for a full description. (Contributed by Dennis Sweeney in bpo-39939.)
Type Hinting Generics in Standard Collections
In type annotations you can now use built-in collection types such as list and dict as generic types instead of importing the corresponding capitalized types (e.g. List or Dict) from typing. Some other types in the standard library are also now generic, for example queue.Queue.
Example:
def greet_all(names: list[str]) - None:
for name in names:
print("Hello", name)
See PEP 585 for more details. (Contributed by Guido van Rossum, Ethan Smith, and Batuhan Taşkaya in bpo-39481.)
New Parser
Python 3.9 uses a new parser, based on PEG instead of LL(1). The new parser’s performance is roughly comparable to that of the old parser, but the PEG formalism is more flexible than LL(1) when it comes to designing new language features. We’ll start using this flexibility in Python 3.10 and later.
The ast module uses the new parser and produces the same AST as the old parser.
In Python 3.10, the old parser will be deleted and so will all functionality that depends on it (primarily the parser module, which has long been deprecated). In Python 3.9 only, you can switch back to the LL(1) parser using a command line switch (-X oldparser) or an environment variable (PYTHONOLDPARSER=1).
See PEP 617 for more details. (Contributed by Guido van Rossum, Pablo Galindo and Lysandros Nikolaou in bpo-40334.)
Other Language Changes
__import__() now raises ImportError instead of ValueError, which used to occur when a relative import went past its top-level package. (Contributed by Ngalim Siregar in bpo-37444.)
Python now gets the absolute path of the script filename specified on the command line (ex: python3 script.py): the _file_ attribute of the _main_ module became an absolute path, rather than a relative path. These paths now remain valid after the current directory is changed by os.chdir(). As a side effect, the traceback also displays the absolute path for _main_ module frames in this case. (Contributed by Victor Stinner in bpo-20443.)
In the Python Development Mode and in debug build, the encoding and errors arguments are now checked for string encoding and decoding operations. Examples: open(), str.encode() and bytes.decode().
By default, for best performance, the errors argument is only checked at the first encoding/decoding error
New Modules
sudo add-apt-repository ppa:deadsnakes/ppa
sudo apt update
sudo apt install python3.9
● Zatiel
💟◣Compra en Amazon y ayuda a crecer el canal◥ ➡MX: https://amzn.to/3djo8sD
💟 ◣Apoya al canal En Patreon◥ ➡ / zatiel
💟 ◣Apoya al canal realizando una donación en PayPal◥ ➡ https://www.paypal.me/zatiel
💟💟💟 Amazon Wish List ➡ https://www.amazon.com.mx/hz/wishlist...
● Suscribete:➡ / @zatielfx
- Connect with Me! -
★ Twitch: ➡ / zatiel
★ Twitter: ➡ / callmezatiel
💟 Portafolio ➡ https://dzn.gg/profile/1154-zatiel/
★ ★ Grupo de Facebook Siren Linux ➡ / sirenlinux
★ Instagram:➡ / callmezatiel
★ Facebook:➡ / callmezatiel
★ Spotify Play List: ➡ https://open.spotify.com/playlist/2SM...
★ Correo Patrocinios / Colaboraciones: [email protected]
● Canal Secundario:
/ @zatielfx
This tutorial will apply for computers, laptops, desktops, and tablets running the Windows 11 operating system (Home, Professional, Enterprise, Education) from all supported hardware manufactures, like Dell, HP, Acer, Asus, Toshiba, Lenovo, Huawei and Samsung.
#python #bash #terminal