import sys
old_open = __builtins__.open

def my_open(fname, *args, **kwargs):
    if os.path.isfile(fname) and os.stat(fname).st_nlink > 1:
        os.unlink(fname)
return old_open(fname, *args, **kwargs)
__buitlins__.open = my_open
Python copy-on-write using hardlinks