Loading topic
print and basic string operations. It also assumes you know what files, directories, and absolute and relative paths are on your operating system. You need Python 3.6 or newer. The examples use Python 3.12 behavior.4 min readPath objects from the previous chapter, Python 3.9 or later, and what a file system is. By the end you should know which pathlib classes only work on path text, which ones also talk to the disk, and when to choose each.5 min readPath object is from the earlier chapters. You should also know that a path can be relative or absolute. Here you will learn how / combines path pieces, what happens at the edges, and how to join untrusted input safely.5 min readPath object stores a path as a sequence of components, not as one string. You read those components through attributes, so you never need str.split("/"), rsplit(".", 1), or slicing. This chapter covers each attribute and its edge cases, and the mistakes that come from misreading them.4 min readPath with the / operator and read its attributes (name, stem, suffix, parent, parts). Those are covered in the two previous chapters. Here you will use those attributes to produce new paths, such as an output file next to an input file or a path ins4 min readPath objects, as covered in the earlier chapters. You should also know the difference between a relative and an absolute path. Here you will learn where a relative path points, how to find the user's home directory, and how to turn a messy path int6 min readPath with the / operator and that you know the difference between pure and concrete paths. Until now, most operations only manipulated text. The methods in this chapter ask the operating system about a path, so they belong to concrete paths (Path, not `Pure5 min readPath objects (the / operator, name, suffix, parent) and that you know how to check exists(), is_file(), and is_dir(). It also assumes you know the difference between text and bytes in Python. Here you will use Path objects to move data5 min readPath.mkdir() and listing their contents with Path.iterdir(). It assumes you can build paths with /, take them apart, and check them with exists(), is_file() and is_dir(). It also assumes you can read and write small files with read_text() and5 min readPath.glob() and Path.rglob(), the pathlib methods that search a directory for names matching a pattern. It assumes you can already build Path objects, use exists(), is_file() and is_dir(), and create directories with mkdir(). It also assumes you know what a generato5 min readPath methods that change or describe things that already exist on disk: renaming and moving, deleting, and reading metadata such as size and modification time. It assumes you can build Path objects, check whether they exist, and read and write files with read_text and `5 min readPath objects, join them with /, and read and write files with Path methods, as covered in earlier chapters. It also assumes you know basic exception handling and type hints.6 min read/, reading name, suffix and parent, and the split between pure paths and concrete paths. Here you will use that split to work with paths from a different operating system than the one your code runs on.5 min readpathlib code. It assumes you can already build paths with /, read their parts, query the file system, and use glob. It also assumes Python 3.9 or newer, because several fixes use is_relative_to(), which was added in 3.9.5 min read