#NEWLINE# def replace_assign( data , varname , new_value ) : #NEWLINE# #INDENT# ASSIGN_RE = re . compile ( BASE_ASSIGN_PATTERN . format ( varname ) ) #NEWLINE# def repl( m ) : #NEWLINE# #INDENT# return ( ( m . group ( 1 ) + new_value ) + m . group ( 3 ) ) #NEWLINE# #UNINDENT# return ASSIGN_RE . sub ( repl , data )