From the course: Learning Python

Unlock the full course today

Join today to access over 23,200 courses taught by industry experts.

Using filesystem shell methods

Using filesystem shell methods - Python Tutorial

From the course: Learning Python

Using filesystem shell methods

- [Instructor] So far in this chapter, we've seen how to create files and how to get information about files, and Python provides a set of utilities for manipulating files using the operating system's shell utilities, and that's what we're going to look at in this example. So let's start by opening up the Shell_start code. To use the shell utilities, I first need to import the SH Util module into my app, so let's do that first. So I'll import SH Util, and you can see that I've already imported the OS and the OS path modules into my app as well. So, we'll start off doing something pretty simple. Let's just make a duplicate or a copy of an existing file. Now, this example depends on the Textfile.txt file existing, and you can see I've got it over here in my file browser. If it's not there for you, it's probably because you didn't do one of the previous exercises in the chapter, and you just need to do one of the previous…

Contents