MCPcopy Index your code
hub / github.com/python/cpython / __getitem__

Method __getitem__

Lib/annotationlib.py:452–469  ·  view source on GitHub ↗
(self, other)

Source from the content-addressed store, hash-verified

450 return id(self)
451
452 def __getitem__(self, other):
453 # Special case, to avoid stringifying references to class-scoped variables
454 # as '__classdict__["x"]'.
455 if self.__ast_node__ == "__classdict__":
456 raise KeyError
457 if isinstance(other, tuple):
458 extra_names = {}
459 elts = []
460 for elt in other:
461 new_elt, new_extra_names = self.__convert_to_ast_getitem(elt)
462 if new_extra_names is not None:
463 extra_names.update(new_extra_names)
464 elts.append(new_elt)
465 other = ast.Tuple(elts)
466 else:
467 other, extra_names = self.__convert_to_ast_getitem(other)
468 assert isinstance(other, ast.AST), repr(other)
469 return self.__make_new(ast.Subscript(self.__get_ast(), other), extra_names)
470
471 def __getattr__(self, attr):
472 return self.__make_new(ast.Attribute(self.__get_ast(), attr))

Callers

nothing calls this directly

Calls 5

__make_newMethod · 0.95
__get_astMethod · 0.95
updateMethod · 0.45
appendMethod · 0.45

Tested by

no test coverage detected