def _container_getitem(instance, elts, index, context=None):
try:<EOL><INDENT>if isinstance(index, Slice):<EOL><INDENT>index_slice = _infer_slice(index, context=context)<EOL>new_cls = instance.__class__()<EOL>new_cls.elts = elts[index_slice]<EOL>new_cls.parent = instance.parent<EOL>return new_cls<EOL><DEDENT>if isinstance(index, Const):<EOL><INDENT>return elts[index.value]<EOL><DEDENT><DEDENT>except IndexError as exc:<EOL><INDENT>raise exceptions.AstroidIndexError(<EOL>message="<STR_LIT>",<EOL>node=instance,<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=instance, index=index, context=context<EOL>) from exc<EOL><DEDENT>raise exceptions.AstroidTypeError("<STR_LIT>" % index)<EOL>
Get a slice or an item, using the given *index*, for the given sequence.