docstr: Open a file named `filename` in a temporary directory.
  
  This context manager is preferred over `NamedTemporaryFile` in
  stdlib `tempfile` when one needs to reopen the file.
  
  Arguments `mode` and `bufsize` are passed to `open`.
  Rest of the arguments are passed to `TemporaryDirectory`.
docstr_tok: ["Open","a","file","named","`","filename","`","in","a","temporary","directory",".","This","context","manager","is","preferred","over","`","NamedTemporaryFile","`","in","stdlib","`","tempfile","`","when","one","needs","to","reopen","the","file",".","Arguments","`","mode","`","and","`","bufsize","`","are","passed","to","`","open","`",".","Rest","of","the","arguments","are","passed","to","`","TemporaryDirectory","`","."]
code: def __init__(
      self,
      filename,
      mode="w+b",
      bufsize=-1,
      add_to_syspath=False,
      **kwds,
  ):
      """
      Open a file named `filename` in a temporary directory.
  
      This context manager is preferred over `NamedTemporaryFile` in
      stdlib `tempfile` when one needs to reopen the file.
  
      Arguments `mode` and `bufsize` are passed to `open`.
      Rest of the arguments are passed to `TemporaryDirectory`.
  
      """
      self._tmpdir = TemporaryDirectory(**kwds)
      path = Path(self._tmpdir.name) / filename
      encoding = None if "b" in mode else "utf-8"
      self.file = open(path, mode, bufsize, encoding=encoding)
  
file_path: catboost/contrib/python/ipython/py3/IPython/utils/tempdir.py
imports: import os
  from pathlib import Path
  from tempfile import TemporaryDirectory
label_desc: Use image node_id 1 to create a new NamedFileInTemporaryDirectory object from inherited base classes: object with example: obj = NamedFileInTemporaryDirectory(filename, mode, bufsize, add_to_syspath)