5

Open function python

Synonyms:

  1. File like objects
  2. Streams

Related: Difference between File and Stream?

Summary(jak):

These are just like another object with standard methods or interfaces- read(), write(), etc - . They allow interactions with underlying resource through the standard interface.

File object

https://docs.python.org/3/glossary.html#term-file-object An object exposing a file-oriented API (with methods such as read() or write()) to an underlying resource. Depending on the way it was created, a file object can mediate access to a real on-disk file or to another type of storage or communication device (for example standard input/output, in-memory buffers, sockets, pipes, etc.). File objects are also called file-like objects or streams. There are actually three categories of file objects: raw binary files, buffered binary files and text files. Their interfaces are defined in the io module. The canonical way to create a file object is by using the open() function. file-like object A synonym for file object.

Three types of File objects

There are actually three categories of file objects:

  1. raw binary files,
  2. buffered (Buffer) binary files and
  3. text files.

Their interfaces are defined in the io module. The canonical way to create a file object is by using the open() function. Glossary

File-oriented API

https://nirolution.com/api-types/#4 You can address a file-oriented programming interface via normal calls open, read, write and close. So, when you send data to an object, it is written with write, when it is to be received, it is read, and when it is to be closed, close is used.