def _create_carefully(path):
 fd = os.open(path, ((os.O_CREAT | os.O_EXCL) | os.O_RDWR), 438)
 try:
  return open(path, 'rb+')
 finally:
  os.close(fd)

def _create_carefully ( path ) : fd = os . open ( path , ( ( os . O_CREAT | os . O_EXCL ) | os . O_RDWR ) , 438 ) try : return open ( path , 'rb+' ) finally : os . close ( fd )
create a file if it doesnt exist and open for reading and writing .