Python 3.9 Improves Dictionary Handling
Written by Kay Ewbank   
Wednesday, 07 October 2020

Python has been updated with a new release that improves dictionary handling and adds new string methods.

Python 3 has been developed since 2008 while the Python 2.x line has remained in use. While the .9 part of the name might sound as though Python 4 is just around the corner, that's not the case according to the development team. They say the next release after 3.9 will be 3.10, which will be an incremental improvement over 3.9, just as 3.9 was over 3.8, and so on. Python 3.10 will be available this time next year, though the first alpha release of what will become 3.10.0 a year from now is available to try out now.

python3

The first improvement to the latest release is the addition of Merge (|) and update (|=) operators to the dictionary class. The additions were made because the existing ways to merge two dicts have several disadvantages, such as needing a temporary variable or being hard to discover and difficult to understand.

The second improvement of note is the provision of new string methods for removing prefixes and suffixes. The developers say these have been added because users have been confused when trying to use the existing str.lstrip and str.rstrip methods to remove prefixes and suffixes. The new removeprefix and removesuffix actually behave the way users expect. Alongside the string methods, bytes, bytearray, and collections.UserString methods have also been added.

Python 3.9 also includes a new parser based on PEG rather than on LL(1), as was the case with the old parsers. The new parser is no faster than the old one, but it is more flexible. The development team say the new parser should eliminate the multiple "hacks" that exist in the current grammar to circumvent the LL(1)-limitation, so reducing the maintenance costs and lifting the LL(1) restriction on the current Python grammar.

Python 3.9 also has a new library module, the IANA Time Zone Database. Python's datetime library uses a flexible mechanism to handle time zones, and users can implement arbitrarily complex time zone rules, but in practice the majority of users want support for just three types of time zone: - UTC, system local time and IANA time zones. This addition adds that support.

python3

 

More Information

Python HomePage

Related Articles

Python 3.8 Adds Walrus Operator

Python Language Summit 2020 - Python Typing

 

 

To be informed about new articles on I Programmer, sign up for our weekly newsletter, subscribe to the RSS feed and follow us on Twitter, Facebook or Linkedin.

Banner


OpenJS Foundation Launches jQuery Website Checker
23/04/2024

The OpenJS Foundation has launched a new website checker tool that detects if the jQuery used is out of date.



Actionforge Releases GitHub Actions VSCode Extension
09/04/2024

Actionforge has released the beta of its GitHub Actions tool as a VS Code extension. The extension consists of a suite of tools making up a visual node system for building and managing GitHub Actions  [ ... ]


More News

raspberry pi books

 

Comments




or email your comment to: comments@i-programmer.info

<ASIN:1871962587>

<ASIN:B07S1K8KLW>

Last Updated ( Wednesday, 07 October 2020 )