code: def match_dict_keys(keys, prefix, delims):
      """Used by dict_key_matches, matching the prefix to a list of keys"""
      if not prefix:
          return (
              None,
              0,
              [
                  repr(k)
                  for k in keys
                  if isinstance(k, (string_types, bytes))
              ],
          )
      quote_match = re.search("[\"']", prefix)
      quote = quote_match.group()
      try:
          prefix_str = eval(prefix + quote, {})
      except Exception:
          return None, 0, []
  
      pattern = "[^" + "".join("\\" + c for c in delims) + "]*$"
      token_match = re.search(pattern, prefix, re.UNICODE)
      token_start = token_match.start()
      token_prefix = token_match.group()
  
      # TODO: support bytes in Py3k
      matched = []
      for key in keys:
          try:
              if not key.startswith(prefix_str):
                  continue
          except (AttributeError, TypeError, UnicodeError):
              # Python 3+ TypeError on b'a'.startswith('a') or vice-versa
              continue
  
          # reformat remainder of key to begin with prefix
          rem = key[len(prefix_str) :]
          # force repr wrapped in '
          rem_repr = repr(rem + '"')
          if rem_repr.startswith("u") and prefix[0] not in "uU":
              # Found key is unicode, but prefix is Py2 string.
              # Therefore attempt to interpret key as string.
              try:
                  rem_repr = repr(rem.encode("ascii") + '"')
              except UnicodeEncodeError:
                  continue
  
          rem_repr = rem_repr[1 + rem_repr.index("'") : -2]
          if quote == '"':
              # The entered prefix is quoted with ",
              # but the match is quoted with '.
              # A contained " hence needs escaping for comparison:
              rem_repr = rem_repr.replace('"', '\\"')
  
          # then reinsert prefix from start of token
          matched.append("%s%s" % (token_prefix, rem_repr))
      return quote, token_start, matched
  
imports: from __future__ import print_function
  import __main__
  import glob
  import inspect
  import itertools
  import keyword
  import os
  import re
  import sys
  import unicodedata
  import string
  import warnings
  from traitlets.config.configurable import Configurable
  from IPython.core.error import TryNext
  from IPython.core.inputsplitter import ESC_MAGIC
  from IPython.core.latex_symbols import latex_symbols, reverse_latex_symbol
  from IPython.utils import generics
  from IPython.utils.decorators import undoc
  from IPython.utils.dir2 import dir2, get_real_method
  from IPython.utils.process import arg_split
  from IPython.utils.py3compat import builtin_mod, string_types, PY3, cast_unicode_py2
  from traitlets import Bool, Enum, observe
label_desc: Use image node_id 7 for calling a global function with example usage: match_dict_keys(keys, prefix, delims) and returns: quote,  token_start,  matched, None,  int,  unknown, None,  int,  list