code: def indent(text, prefix, predicate=None):
      """Adds 'prefix' to the beginning of selected lines in 'text'.
  
      If 'predicate' is provided, 'prefix' will only be added to the lines
      where 'predicate(line)' is True. If 'predicate' is not provided,
      it will default to adding 'prefix' to all non-empty lines that do not
      consist solely of whitespace characters.
      """
      if predicate is None:
          # str.splitlines(True) doesn't produce empty string.
          #  ''.splitlines(True) => []
          #  'foo\n'.splitlines(True) => ['foo\n']
          # So we can use just `not s.isspace()` here.
          predicate = lambda s: not s.isspace()
  
      prefixed_lines = []
      for line in text.splitlines(True):
          if predicate(line):
              prefixed_lines.append(prefix)
          prefixed_lines.append(line)
  
      return "".join(prefixed_lines)
  
file_path: cpython/Lib/textwrap.py
imports: import re
label_desc: Use image node_id 5 for calling a global function with example usage: indent(text, prefix, predicate) and returns: str