|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.
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.
or email your comment to: firstname.lastname@example.org
|Last Updated ( Wednesday, 07 October 2020 )|