Skip to main content
PProfileMatch
← Path

Python Fundamentals · Python File Handling, Exceptions and Modules

0 XP
  1. 1 current stop: learning
  2. 2 upcoming
  3. 3 upcoming
  4. 4 upcoming
  5. 5 upcoming

Finish after stop 5

Stop 1 of 5 · Depot filing cabinet

Trick to keep in mind+3 XP

w wipes, a adds: one wrong letter and yesterday's file is gone

open(path, "w") empties the file at the moment it opens, and no error warns you. "a" positions at the end and keeps what's there, "r" only reads, and "x" creates a file but refuses if it already exists. Check the mode letter every time you write.

Read it once, then a question tests whether the trick stuck.