#NEWLINE# def node_assign( self , node , val ) : #NEWLINE# #INDENT# 'here we assign a value (not the node.value object) to a node\n        this is used by on_assign, but also by for, list comprehension, etc.\n        ' #NEWLINE# if ( len ( self . error ) > 0 ) : #NEWLINE# #INDENT# return #NEWLINE# #UNINDENT# if ( node . __class__ == ast . Name ) : #NEWLINE# #INDENT# sym = self . symtable . set_symbol ( node . id , value = val ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( node . __class__ == ast . Attribute ) : #NEWLINE# #INDENT# if ( node . ctx . __class__ == ast . Load ) : #NEWLINE# #INDENT# errmsg = ( 'cannot assign to attribute %s' % node . attr ) #NEWLINE# self . raise_exception ( node , exc = AttributeError , msg = errmsg ) #NEWLINE# #UNINDENT# setattr ( self . run ( node . value ) , node . attr , val ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( node . __class__ == ast . Subscript ) : #NEWLINE# #INDENT# sym = self . run ( node . value ) #NEWLINE# xslice = self . run ( node . slice ) #NEWLINE# if isinstance ( node . slice , ast . Index ) : #NEWLINE# #INDENT# sym [ xslice ] = val #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if isinstance ( node . slice , ast . Slice ) : #NEWLINE# #INDENT# i = xslice . start #NEWLINE# sym [ slice ( xslice . start , xslice . stop ) ] = val #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if isinstance ( node . slice , ast . ExtSlice ) : #NEWLINE# #INDENT# sym [ xslice ] = val #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# if ( node . __class__ in ( ast . Tuple , ast . List ) ) : #NEWLINE# #INDENT# if ( len ( val ) == len ( node . elts ) ) : #NEWLINE# #INDENT# for ( telem , tval ) in zip ( node . elts , val ) : #NEWLINE# #INDENT# self . node_assign ( telem , tval ) #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# raise ValueError ( 'too many values to unpack' )