Python - File writable() Method


Advertisements

The Python file writable() method is used to check whether the specified file is writable or not. It returns true if the specified file is writable, else returns false.

Syntax


file.writable()

Parameters

No parameter is required.

Example: Check a file, writable or not

In the below example, Python file writable() method is used to check whether the file called MyFile is writable or not. As it is not a writable file, it returns False.

MyFile = open("python_test.txt")
print(MyFile.writable())

Output

False

Python File Handling Methods
Advertisements