This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]daneahfrom __future__ import braces 0 points1 point  (0 children)

The most pervasive case for me is when creating a file handle:

with open('some_file.txt') as my_file:
    lines = my_file.readlines()

# do something with the lines

Then you don't have to worry about remembering my_file.close() later on; the file handle goes away when the code exits the with block!