Python Keylogger Tutorial - 3 - 'with' keyword in Python

Pubblicato il: 02 gennaio 2019
sul canale di: buildwithpython
21,988
342

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


In questa pagina del sito puoi guardare il video online Python Keylogger Tutorial - 3 - 'with' keyword in Python della durata di ore minuti seconda in buona qualità , che l'utente ha caricato buildwithpython 02 gennaio 2019, condividi il link con amici e conoscenti, su youtube questo video è già stato visto 21,988 volte e gli è piaciuto 342 spettatori. Buona visione!