code: def _get_or_open_file(filename):
          '''If ``filename`` is a string or bytes object, open the
          ``filename`` and return the file object. If ``filename`` is
          file-like (i.e., it has 'read' and 'write' attributes, return
          ``filename``.
  
          Parameters
          ----------
          filename : str, bytes, file
  
          Raises
          ------
          TypeError
              If ``filename`` is not a string, bytes, or file-like
              object.
  
              File-likeness is determined by checking for 'read' and
              'write' attributes.
          '''
          if isinstance(filename, (str, bytes)):
              f = open(filename)
          elif hasattr(filename, 'read') and hasattr(filename, 'write'):
              f = filename
          else:
              raise TypeError('filename must be str or bytes, or a file')
          return f _get_or_open_file(filename):
          '''If ``filename`` is a string or bytes object, open the
          ``filename`` and return the file object. If ``filename`` is
          file-like (i.e., it has 'read' and 'write' attributes, return
          ``filename``.
  
          Parameters
          ----------
          filename : str, bytes, file
  
          Raises
          ------
          TypeError
              If ``filename`` is not a string, bytes, or file-like
              object.
  
              File-likeness is determined by checking for 'read' and
              'write' attributes.
          '''
          if isinstance(filename, (str, bytes)):
              f = open(filename)
          elif hasattr(filename, 'read') and hasattr(filename, 'write'):
              f = filename
          else:
              raise TypeError('filename must be str or bytes, or a file')
          return f
docs: If ``filename`` is a string or bytes object, open the
          ``filename`` and return the file object. If ``filename`` is
          file-like (i.e., it has 'read' and 'write' attributes, return
          ``filename``.
  
          Parameters
          ----------
          filename : str, bytes, file
  
          Raises
          ------
          TypeError
              If ``filename`` is not a string, bytes, or file-like
              object.
  
              File-likeness is determined by checking for 'read' and
              'write' attributes.