# File Mode

*noun*

say it: **“FYLE MOHD”** **/ˈfaɪl moʊd/**

The letter that tells open() what you plan to do with a file: "r" read (the default), "w" write (wiping the file first) or "a" add to the end.

## What is a **file mode**?

A **file mode** tells `open()` what you plan to do: `"r"` read (the default), `"w"` write (wipes the file first), `"a"` add to the end.

```python
with open("log.txt", "a") as file:
    file.write("User logged in\n")
```

## In a sentence

- “Choosing the **file mode** "w" erased the old scores.”
- “The log opens with the **file mode** "a", so each run adds a line.”

Level: Apprentice · [More Python terms at this level](https://www.ask-codey.com/glossary?category=python&level=2)

Updated: November 19, 2026

Source: https://www.ask-codey.com/glossary/file-mode
