There are different modes you can open a file with, specified by the mode parameter. These include:

with open(filename, 'r') as f:
    f.read()
with open(filename, 'w') as f:
    f.write(filedata)
with open(filename, 'a') as f:
    f.write('\\n' + newdata)

Untitled Database

Python 3 added a new mode for exclusive creation so that you will not accidentally truncate or overwrite and existing file.