#NEWLINE# def __setitem__( self , variable , binding ) : #NEWLINE# #INDENT# "\n        A binding is consistent with the dict if its variable is not already bound, OR if its\n        variable is already bound to its argument.\n\n        :param variable: ``Variable`` The variable to bind\n        :param binding: ``Expression`` The atomic to which 'variable' should be bound\n        :raise BindingException: If the variable cannot be bound in this dictionary\n        " #NEWLINE# assert isinstance ( variable , Variable ) #NEWLINE# assert isinstance ( binding , Expression ) #NEWLINE# try : #NEWLINE# #INDENT# existing = self [ variable ] #NEWLINE# #UNINDENT# except KeyError : #NEWLINE# #INDENT# existing = None #NEWLINE# #UNINDENT# if ( ( not existing ) or ( binding == existing ) ) : #NEWLINE# #INDENT# self . d [ variable ] = binding2 #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if isinstance ( binding , IndividualVariableExpression ) : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# existing = self [ binding . variable ] #NEWLINE# #UNINDENT# except KeyError : #NEWLINE# #INDENT# existing = None #NEWLINE# #UNINDENT# binding2 = VariableExpression ( variable ) #NEWLINE# if ( ( not existing ) or ( binding2 == existing ) ) : #NEWLINE# #INDENT# self . d [ binding . variable ] = binding2 #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# raise BindingException ( ( 'Variable %s already bound to another value' % variable ) ) #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# raise BindingException ( ( 'Variable %s already bound to another value' % variable ) )