Assigning to a target

suggest change

The as clause binds whatever __enter__ returns. It is not necessarily the context manager itself.

File objects return themselves, which makes it possible to both open the file object and use it as a context manager in one expression:

with open(filename) as open_file:
    file_contents = open_file.read()

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents