Practical Recipes for Working With Files in Python (Overview)
Python has several built-in modules and functions for handling files. These functions are spread out over several modules such as os
, os.path
, shutil
, and pathlib
, to name a few. This course gathers in one place many of the functions you need to know in order to perform the most common operations on files in Python.
In this course, you’ll learn how to:
- Retrieve file properties
- Create directories
- Match patterns in filenames
- Traverse directory trees
- Make temporary files and directories
- Delete files and directories
- Copy, move, or rename files and directories
- Create and extract ZIP archives
- Open multiple files using the
fileinput
module
00:00 Hi, and welcome to this Real Python video tutorial series on Working with Files in Python. Over the course of this series, you’re going to learn pretty much anything you could ever want to know about basic file operations in Python. And by basic file operations I mean: creating and deleting files and directories, moving them around, copying them, renaming them, working with archives, working with temporary files, traversing directory trees, and getting file properties.
00:28 The list goes on and on, but pretty much everything here I will cover, and even some things that are not quite on this list. If you are looking to follow along in your own terminal, I would recommend that you take a look at the ZIP file that’s linked below this video, because that will contain all of these sample directories that I’ll be using throughout this series, organized by lesson.
00:49 It should be really convenient for you. So generally, on each lesson I will introduce the lesson, introduce some of the functions that I’ll be using, and then show you the sample directory, and you should look at it in your own terminal so that you can follow along.
Become a Member to join the conversation.