Join us and get access to thousands of tutorials and a community of expert Pythonistas.

Unlock This Lesson

This lesson is for members only. Join us and get access to thousands of tutorials and a community of expert Pythonistas.

Unlock This Lesson

Hint: You can adjust the default video playback speed in your account settings.
Hint: You can set your subtitle preferences in your account settings.
Sorry! Looks like there’s an issue with video playback 🙁 This might be due to a temporary outage or because of a configuration issue with your browser. Please refer to our video player troubleshooting guide for assistance.

Odds and Ends

00:00 In the previous lesson, I showed you the new typing features introduced in Python 3.11. In this lesson, I’ll cover a few smaller additions in this release.

00:11 The ISO standard 8601 describes date formatting that goes year-month-day, etc. The datetime module’s parsing function has been adapted to be able to parse more of the specification. It now handles week numbers and the UTC time indicator.

00:27 Let’s go look at some examples. This script contains a list of strings which follow the ISO spec. Previously, Python only supported a subset of the spec and some of the values, although compliant, would not be parsed. Notice the use of W40.

00:45 That isn’t a typo. That indicates week 40 of the year instead of the month. Likewise with the trailing Zs that indicate UTC, also known as the Zulu time zone. At the bottom of the script, I enumerate through each of these strings and either print the conversion or an error.

01:08 First, I’ll run this script in Python 3.10. Notice how some of the items are not supported. Now in Python 3.11 …

01:25 and all these cases now work. Week 40, day 1 becomes October 3, and the Zulu indicator is handled.

01:37 Floating-point numbers are a bit weird. You’ve probably seen this old surprise. Well, it’s not the only one. Positive or a negative numbers are indicated by a single bit.

01:48 That means that bit can be on for the number zero, and as this surprises some people, the f-string format now supports a modifier that will suppress the sign.

02:04 In case you didn’t believe me … which can result in this little weirdness. Okay, weirdness aside, let’s see a practical example. Consider my small number …

02:22 which I’ve rounded inside of this f-string. That output might freak some people out, so instead,

02:34 the z modifier tells the f-string to normalize the -0.00. Tiny thing, but saves you an ifelse block to catch this weirdness yourself.

02:46 A cleanup effort is underway to remove old libraries. There are hundreds of modules in the standard library, and all of them need to be maintained. Some of them have newer modules that replace their functionality, and some of them just aren’t used anymore, like Telnet.

03:04 PEP 594 proposed the removal of a bunch of dead batteries. They’ve been marked as deprecated and are scheduled for full removal in Python 3.13. The last lesson is next. I’ll summarize the course, speak briefly about whether you should upgrade, and point you at some sources of further investigation.

Become a Member to join the conversation.