code: def get_terminal_width():
      width = 0
      try:
          _, width = _getdimensions()
      except py.builtin._sysex:
          raise
      except:
          # pass to fallback below
          pass
  
      if width == 0:
          # FALLBACK:
          # * some exception happened
          # * or this is emacs terminal which reports (0,0)
          width = int(os.environ.get("COLUMNS", 80))
  
      # XXX the windows getdimensions may be bogus, let's sanify a bit
      if width < 40:
          width = 80
      return width
  
imports: import sys, os, unicodedata
  import py
  from py.builtin import text, bytes
label_desc: Use image node_id 2 for calling a global function with example usage: get_terminal_width() and returns: width