Locked learning resources

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

Unlock This Lesson

Locked learning resources

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

Unlock This Lesson

Miscellaneous

00:00 In the previous lesson, I talked about improvements to the CPython interpreter. This lesson is a mishmash of features in 3.14.

00:09 The pathlib module is where you go to interact with operating system calls to the file system. The key part of the pathlib module is the Path object, which abstracts a filename and you can use that to access the file itself.

00:23 Path has four new methods: .copy() and .copy_into() copy files, the first copying a file to a destination, whereas the second copies a file into a specific directory.

00:34 There are two corresponding move calls that, well, move instead of copy as well.

00:41 A new .info attribute on the Path object contains information about the file. Through it, you can find out if the file exists, is a directory, is a plain file, or is a symlink. Frequent users of pathlib might be surprised by this as these calls already exist directly on Path.

00:59 So what’s this about? I’m not entirely sure. The .info attribute gets populated automatically when you iterate on a directory and it caches certain information.

01:09 As such, there’s a warning that the contents might not be correct. That said, I suspect in some situations this can be a performance boost, as by using the cache, you’re not having to make an additional system call.

01:22 Your mileage may vary.

01:25 There are eight new assertion methods in unittest. Two for checking attributes, two for checking subclassing, and two for StartsWith() and EndsWith().

01:37 I also already mentioned that unittest is one of the command modules that now has color highlighting. Meta, the artist, formerly known as Facebook, has defined a new compression mechanism called Zstandard.

01:50 This has been added to Python. A new module named compression has been created, and all the existing compression libraries have been moved in there.

02:00 If you want to try out Zstandard compression, it’s in the zstd module. For backwards compatibility, the original compression module locations are aliased and have not yet been deprecated.

02:14 Now for the speed round. If you’ve ever used the json.tool module on the command line to pretty print JSON, well, it’s been aliased so you don’t have to type as much.

02:24 Three new universally unique identifier types have been added: being uuid6(), uuid7(), and uuid8(). The Unicode database has been updated to version 16.0.

02:34 That includes over 5,000 new symbols, including the harp, the shovel, splat, this creepy tree, and a face with bags under its eyes.

02:43 Oh, and since 3.14 are the first three digits of pi, there’s a little Easter egg. When you use the venv tool to create a virtual environment, within that environment, there are aliases for the Python interpreter.

02:55 This is why you can use both python and python3, for example. Well, in honor of the most famous mathematical constant, there is also an alias named π-thon.

03:06 Get it? Aren’t they clever? Offer void for some operating systems.

03:12 Last up, I’ll summarize the course and point you at a whole bunch of references where you can dig in further if you want to know more.

Become a Member to join the conversation.