Python Jumpstart by Building 10 Apps Transcripts
Chapter: App 8: File Searcher App
Lecture: Introduction to the File Searcher App

Login or purchase this course to watch this video and the rest of the course contents.
0:00 Hello and welcome to app number 8. This is a file searching app, and it's going to be able to search for text
0:07 within files across a massive quantity and number of files. So, let's see exactly how this is going to work.
0:15 What are we going to build- well, it's going to look like this, header, as always, and then it's going to ask the user
0:21 what directory do you want to start searching in and we'll search recursively through that entire tree that subdirectory sort of thing,
0:28 and what text, what string you want to look for. Here we are looking in our previous app for the word dragon,
0:34 and here you can see we've found two matches, in the players.py file on line 7 you can see we are defining
0:40 a class called dragon that is derived from creature, so there the word dragon appeared. And then, in the program.py on line 24,
0:47 we found where we were using the name space from the other module to actually allocate or initialize a dragon and this is what a dragon with level 50-
0:55 Now we just say that's it, total number matches was two, we are done. You might think that this app is largely about files.
1:03 But it's not, we've spent a lot of time on working with directories and files and so on,
1:07 we will have to do that, yes, but that's not the primary focus, what we are going to look at is actually how do we use this concept
1:14 of a generator method which is implemented with the yield and yield from keywords, along with recursion to put together a pipeline of processing,
1:23 a chain of what are called generator methods that are extremely efficient at processing large quantities of data
1:30 so you'll see that we are using this app to actually search through like 2.5 gigs of text files, the memory usage is almost 0 above just standard,
1:41 hey what's your name sort of input type of app and the key to making this work is the yield keyword and the generator methods.
1:49 We are going to talk about path operations and very basic string searching but we are going to focus on this concept of a processing pipeline
1:56 and we just happen to use files directories and text as our input.


Talk Python's Mastodon Michael Kennedy's Mastodon