file.writable() Is writable
Last updated: 2026-09-22
file.writable() Is writable
file.writable() returns whether the file supports writing.
| Category | File Methods |
|---|---|
| Kind | Built-in Type Method |
| Python Version | all |
📝 Syntax
file.writable()
Returns:bool. True if the file supports writing, else False.
Mutates the original:No (returns a new object)
▶ Example
Edit the code, press Run, and see the result in the output panel:
Output:
True
False
💡 Related Cases
More case studies coming soon — check back later.
❓ FAQ
QWhat does writable() check?
AWhether the file supports writing. A file opened in 'r' mode returns False.
QWhat is it useful for?
AChecking before writing to avoid OSError.
QIs a file opened with 'w' always writable?
AYes; modes such as 'w', 'a', and 'r+' return True; a read-only 'r' open returns False.