You cannot remove a file handle, only a file path, since multiple paths can refer to the same file and some files (like sockets) don't even have paths. Therefore:
import os
f = open('/tmp/test.txt', 'w')
os.unlink(f.name)
# You can still use f here, it's just only visible for people having a handle.
# close it when you're finished.
However, you should not do that - there's a better way to solve your problem. Use the tempfile module which deletes the file automatically, or just write to /dev/null if you just need a file handle and don't care about the content being written.