#NEWLINE# def write_if_changed( text , outfilename ) : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# oldtext = open ( outfilename , 'r' ) . read ( ) #NEWLINE# if ( text == oldtext ) : #NEWLINE# #INDENT# return #NEWLINE# #UNINDENT# #UNINDENT# except FileNotFoundError : #NEWLINE# #INDENT# pass #NEWLINE# #UNINDENT# open ( outfilename , 'w' ) . write ( text )