file object

The object returned by open() that you read from or write to, and close when finished.

In more detail

It has methods such as read, readline, readlines, write and close, and it can be looped over one line at a time. Opening it in a with statement closes it automatically. Beginners often mix up three things: the file name, the file object and the text read from it.

Related terms

Taught in

References

Certification courses