A Complete List of Python File Methods

Hello dear readers! Welcome back to another edition of our tutorial on Python. In this tutorial guide, i am going to be dropping you guys with the complete table of Python file methods.

A file object is created using the open function and below is the list of functions which can be called on this object -

Sr.No.Methods with Description
Close the file. A closed file cannot be read or written any more.
Flush the internal buffer, like stdio's fflush. This may be a no-op on some file-like objects.
Returns the integer file descriptor that is used by the underlying implementation to request I/O operations from the operating system.
Returns True if the file is connected to a tty(-like) device, else False.
Returns the next line from the file each time it is being called.
Reads at most size bytes from the file (less if the read hits EOF before obtaining size bytes).
Reads one entire line from the file. A trailing newline character is kept in the string.
Reads until EOF using readline() and return a list containing the lines. If the optional sizehint argument is present, instead of reading up to EOF, whole lines totalling approximately sizehint bytes (possibly after rounding up to an internal buffer size) are read.
9file.seek(offset[, whence])
Sets the file's current position
Returns the file's current position
Truncates the file's size. If the optional size argument is present, the file is truncated to (at most) that size.
Writes a string to the file. There is no return value.
Writes a sequence of strings to the file. The sequence can be any iterable object producing strings, typically a list of strings.

The above methods is going to be discussed in details in our future tutorials.

Alright guys! This is where we are rounding up for this tutorial guide. In our next tutorial, we are going to be studying about the Python File close() Method.

Feel free to ask your questions where necessary and i will attend to them as soon as possible. If this tutorial was helpful to you, you can use the share button to share this tutorial.

Follow us on our various social media platforms to stay updated with our latest tutorials. You can also subscribe to our newsletter in order to get our tutorials delivered directly to your emails.

Thanks for reading and bye for now.