Join Barron Stone for an in-depth discussion in this video Searching directories, part of Code Clinic: Python.
- In this video, I'll demonstrate how to use…the os module's walk function…to recursively search a directory.…Looking at the captionsort.py script,…I've used the import statement…to bring in the Python os module.…The os module provides access…to the operating system dependent functionality.…In this case, we'll be using it to access…and create directories.…The program here is structured as a Python class…called caption sort.…We're going to ignore these first three methods in the class…because they're purely focused on generating…the gooey with tkinter.…
For this video, and the next two,…we'll be looking at the sort callback method,…which is executed when the user clicks…on the Sort Images button.…And in this video, we'll only concern ourself…with the first five lines of the sort callback.…This first section of code recursively searches…the specified source directory…to find image files.…And it begins by creating an empty list…to hold the file paths as we discover them.…Next, it retrieves the specified source directory…
Barron introduce challenges and provides an overview of his solutions in Python. Challenges include topics such as statistical analysis, searching directories for images, and accessing peripheral devices.
Visit other courses in the series to see how to solve the exact same challenges in languages like C#, C++, Java, PHP, and Ruby.
Skill Level Intermediate
Q: Why can't I access the Lake Pend Orielle site (http://lpo.dt.navy.mil)?
A: The Lake Pend Orielle site is not accessible in some geographical areas. We have contacted the owner of the server to try to resolve this issue.
Q: I am unable to access the Lake Pend Oreille data from outside the U.S.
A: A static copy of this data is provided here for lynda.com members outside of the U.S
Problem One: Exploring Lake Pend Oreille
Problem Two: Image Analysis
Problem Three: Eight Queens
Problem Four: Accessing Peripherals
Problem Five: Recursion and Directories
Problem Six: Building the Web
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
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.