code: def snip_print(str, width=75, print_full=0, header=""):
      """Print a string snipping the midsection to fit in width.
  
      print_full: mode control:
  
        - 0: only snip long strings
        - 1: send to page() directly.
        - 2: snip long strings and ask for full length viewing with page()
  
      Return 1 if snipping was necessary, 0 otherwise."""
  
      if print_full == 1:
          page(header + str)
          return 0
  
      print(header, end=" ")
      if len(str) < width:
          print(str)
          snip = 0
      else:
          whalf = int((width - 5) / 2)
          print(str[:whalf] + " <...> " + str[-whalf:])
          snip = 1
      if snip and print_full == 2:
          if (
              py3compat.input(
                  header + " Snipped. View (y/n)? [N]"
              ).lower()
              == "y"
          ):
              page(str)
      return snip
  
imports: from __future__ import print_function
  import os
  import re
  import sys
  import tempfile
  from io import UnsupportedOperation
  from IPython import get_ipython
  from IPython.core.display import display
  from IPython.core.error import TryNext
  from IPython.utils.data import chop
  from IPython.utils.process import system
  from IPython.utils.terminal import get_terminal_size
  from IPython.utils import py3compat
label_desc: Use image node_id 10 for calling a global function with example usage: snip_print(str, width, print_full, header) and returns: snip, int