Join Barron Stone for an in-depth discussion in this video Searching directories, part of Code Clinic: Python.
- View Offline
- Exercise Files
- 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
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?
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.