code: def file(mode='w+b', suffix='', prefix='tmp', dir=None, ignore_missing=False):
      
      # note: bufsize is not supported in Python3, try to prevent problems
      #       stemming from incorrect api usage
      if isinstance(suffix, int):
          raise ValueError('Passed an integer as suffix. Did you want to '
                           'specify the deprecated parameter `bufsize`?')
  
      fp = tempfile.NamedTemporaryFile(mode=mode,
                                       suffix=suffix,
                                       prefix=prefix,
                                       dir=dir,
                                       delete=False)
      try:
          yield fp
      finally:
          try:
              os.unlink(fp.name)
          except OSError as e:
              # if the file does not exist anymore, ignore
              if e.errno != ENOENT or ignore_missing is False:
                  raise
docs: Create a temporary file.
  
      A contextmanager that creates and returns a named temporary file and
      removes it on exit. Differs from temporary file functions in
      :mod:`tempfile` by not deleting the file once it is closed, making it safe
      to write and close the file and then processing it with an external
      program.
  
      If the temporary file is moved elsewhere later on, `ignore_missing` should
      be set to `True`.
  
      :param mode: Passed on to :func:`tempfile.NamedTemporaryFile`.
      :param suffix: Passed on to :func:`tempfile.NamedTemporaryFile`.
      :param prefix: Passed on to :func:`tempfile.NamedTemporaryFile`.
      :param dir: Passed on to :func:`tempfile.NamedTemporaryFile`.
      :param ignore_missing: If set to `True`, no exception will be raised if the
                             temporary file has been deleted when trying to clean
                             it up.
      :return: A file object with a `.name`.