In the previous video we learned that whenever we use the open function it allocates some resources and memory to the file. And after we use the close function it releases the resources from the system. If we don't realease this memory it might give us some errors. So it's always a good practice to close the file.
Now this memory allocation and then it's release is used not only in file handling but in other kind of things as well. For example, listeners. We will be using these listeners to listen to keystrokes in future videos. But for now just understand that this listener also requires some memory allocation and then after the listener has done it's job we have to release the resources.
Now the function of the 'with' keyword is that it releases the memory automatically. So if use the 'with' keyword we won't have to type in the close function. So let's actually to that.
Now this might seem small of a change to you but when are writing a lot of code sometimes you might forget to release the resources. And this will create a lt of problems. Or if you are using something like listeners in which you don't really know when you are supposed to release the resources the 'with' keyword comes in pretty handy.
Full Playlist - • Building a keylogger using Python + Pynput
Source Code - https://github.com/attreyabhatt/Pytho...
Subscribe - / @buildwithpython
Website - www.buildwithpython.com
Instagram - / buildwithpython
#python
Sur cette page du site, vous pouvez voir la vidéo en ligne Python Keylogger Tutorial - 3 - 'with' keyword in Python durée heure minute seconde en bonne qualité , qui a été Téléchargé par l'utilisateur buildwithpython 02 janvier 2019, Partagez le lien avec vos amis et connaissances, sur youtube cette vidéo a déjà été regardée 21,988 fois et il a aimé 342 téléspectateurs. Bon visionnage!