import os tmp = 'tmp3.dat' permissions = 0o777 with open(tmp, 'w') as f : print('tmpmp', file = f) os.chmod(tmp, permissions) with open(tmp, 'a') as f : print('tmp', file = f)