I'm opening a file in Python using os.open(), and then I want to write to it using the file interface, ie. f.write().
So I'm doing the following
import os
fd = os.open('log', os.O_CREAT|os.O_RDWR, 0b111110110)
f = open(fd,'w')
But when it's time to clean up, I don't know if I should do call both os.close(fd) and f.close(), or only one.
Calling os.close() xor f.close() is fine (ie. exactly one), but calling both throws a "bad file descriptor" error.