- So far in this chapter, we've seen how to create files…and how to get information about files.…Python provides a set of utilities for manipulating files…using the operating system's shell utilities.…And that's what we're going to take a look at…in this example.…So let's start by opening up shell_start.py.…And to use the shell utilities,…I first need to import the Shutil module into my app.…So let's go ahead and do that.…Alright, import Shutil.…
We'll start off by doing something pretty simple.…Let's make a duplicate of an existing file.…Now this example depends on textfile.txt existing.…And if it's not there for you,…it's probably because you didn't do…one of the previous exercises in this chapter.…And you just need to do with the previous exercises…to make sure that this file exists.…First the code uses the path modules exists function…to make sure the file exists,…and then I'm going to use the real path function…to retrieve the path information for the file.…
So I'll make a variable called source…and I'll call path.realpath…
- Installing Python
- Choosing an editor or IDE
- Working with variables and expressions
- Writing loops
- Using the date, time, and datetime classes
- Reading and writing files
- Fetching internet data
- Parsing and processing HTML
Skill Level Beginner
Programming Foundations: Design Patterns (2013)with Elisabeth Robson2h 19m Intermediate
1. Getting Started
2. Python Basics
3. Working with Dates and Time
4. Working with Files
5. Working with Web Data
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.