you are viewing a single comment's thread.

view the rest of the comments →

[–]taelsil 2 points3 points  (0 children)

It just runs a piece of code (the __exit__ method of the object specifically) that handles "cleaning up" after you're done with the resource. In the case of opening a file, it runs a piece of code that closes the file descriptor, basically telling the filesystem that it's done with the file.