I'm writing a prog which writes data into a file, and each hour a new file is generated, with a precise title. When the storage is full, it either stops the application, or deletes the oldest file created in the folder.
fp = open (fileNamePath, 'a')
fp.write('%s' % buffer)
try:
fp.close()
except IOError:
# delete file or close app
But when it comes to the except, it just skips it, and display IOError.
Thanks !
fp.close()
when pasting , also try to use context managersIOError
is raised if the file can't be opened.file.close
doesn't raise anIOError