def p_factor_item(self, p):
def resolve_item(obj, index):<EOL><INDENT>if is_ndarray(obj) or isinstance(obj, (list, tuple)):<EOL><INDENT>if not isinstance(index, int):<EOL><INDENT>raise TypeError("<STR_LIT>".format(index))<EOL><DEDENT><DEDENT>elif isinstance(obj, dict):<EOL><INDENT>if not isinstance(index, (six.string_types, int)):<EOL><INDENT>raise TypeError("<STR_LIT>".format(index))<EOL><DEDENT><DEDENT>else:<EOL><INDENT>raise TypeError("<STR_LIT>".format(type(obj)))<EOL><DEDENT>return obj[index]<EOL><DEDENT>p[<NUM_LIT:0>] = Instruction('<STR_LIT>', context={<EOL>'<STR_LIT>': resolve_item,<EOL>'<STR_LIT>': p[<NUM_LIT:1>],<EOL>'<STR_LIT:index>': p[<NUM_LIT:3>]<EOL>})<EOL>
factor : factor LBRACK conditional RBRACK