class_docstr: Open a file named `filename` in a temporary directory.
  
  This context manager is preferred over :class:`tempfile.NamedTemporaryFile`
  when one needs to reopen the file, because on Windows only one handle on a
  file can be open at a time. You can close the returned handle explicitly
  inside the context without deleting the file, and the context manager will
  delete the whole directory when it exits.
  
  Arguments `mode` and `bufsize` are passed to `open`.
  Rest of the arguments are passed to `TemporaryDirectory`.
  
  Usage example::
  
      with NamedFileInTemporaryDirectory('myfile', 'wb') as f:
          f.write('stuff')
          f.close()
          # You can now pass f.name to things that will re-open the file
class_docstr_tok: ["Open","a","file","named","`","filename","`","in","a","temporary","directory",".","This","context","manager","is","preferred","over",":","class",":","`","tempfile.NamedTemporaryFile","`","when","one","needs","to","reopen","the","file",",","because","on","Windows","only","one","handle","on","a","file","can","be","open","at","a","time",".","You","can","close","the","returned","handle","explicitly","inside","the","context","without","deleting","the","file",",","and","the","context","manager","will","delete","the","whole","directory","when","it","exits",".","Arguments","`","mode","`","and","`","bufsize","`","are","passed","to","`","open","`",".","Rest","of","the","arguments","are","passed","to","`","TemporaryDirectory","`",".","Usage","example",":",":","with","NamedFileInTemporaryDirectory","(","'myfile","'",",","'wb","'",")","as","f",":","f.write","(","'stuff","'",")","f.close","(",")","#","You","can","now","pass","f.name","to","things","that","will","re-open","the","file"]
code: def cleanup(self):
      self.file.close()
      self._tmpdir.cleanup()
  
file_path: catboost/contrib/python/testpath/py2/testpath/tempdir.py
imports: from __future__ import print_function
  import os
  import warnings
  import sys
label_desc: Use image node_id 2 for calling the NamedFileInTemporaryDirectory obj's underlying member method code with example usage: obj.cleanup() without return types