Open function in python

Open function in python

December 12, 2022 | python

Function #

tags
Python, File Object in Python

ref: https://docs.python.org/3/library/functions.html#open

open(file, mode='r', buffering=-1, encoding=None, errors=None, newline=None, closefd=True, opener=None)

Open file and return a corresponding file object(). If the file cannot be opened, an OSError is raised. See Reading and Writing Files for more examples of how to use this function. file is a path-like object giving the pathname (absolute or relative to the current working directory) of the file to be opened or an integer file descriptor of the file to be wrapped. (If a file descriptor is given, it is closed when the returned I/O object is closed, unless closefd is set to False.)

Does open() method loads file into the RAM #

stackoverflow

  • No. As per the docs, open() wraps a system call and returns a file object,
  • the file contents are not loaded into RAM (unless you invoke, E.G., readlines()).


No notes link to this note

Go to random page

Previous Next