def getitem(self, index, context=None):
if isinstance(index, Const):<EOL><INDENT>index_value = index.value<EOL><DEDENT>elif isinstance(index, Slice):<EOL><INDENT>index_value = _infer_slice(index, context=context)<EOL><DEDENT>else:<EOL><INDENT>raise exceptions.AstroidTypeError(<EOL>"<STR_LIT>".format(type(index))<EOL>)<EOL><DEDENT>try:<EOL><INDENT>if isinstance(self.value, (str, bytes)):<EOL><INDENT>return Const(self.value[index_value])<EOL><DEDENT><DEDENT>except IndexError as exc:<EOL><INDENT>raise exceptions.AstroidIndexError(<EOL>message="<STR_LIT>",<EOL>node=self,<EOL>index=index,<EOL>context=context,<EOL>) from exc<EOL><DEDENT>except TypeError as exc:<EOL><INDENT>raise exceptions.AstroidTypeError(<EOL>message="<STR_LIT>", node=self, index=index, context=context<EOL>) from exc<EOL><DEDENT>raise exceptions.AstroidTypeError("<STR_LIT>" % (self, self.value))<EOL>
Get an item from this node if subscriptable.

        :param index: The node to use as a subscript index.
        :type index: Const or Slice

        :raises AstroidTypeError: When the given index cannot be used as a
            subscript index, or if this node is not subscriptable.