{
    "content": [
        {
            "type": "text",
            "text": "# tempfile (pydoc)\n\n**Summary:** tempfile - Temporary files.\n\n## Section Outline\n\n- **NAME** (2 lines)\n- **MODULE REFERENCE** (8 lines)\n- **DESCRIPTION** (22 lines)\n- **CLASSES** (4 lines) — 2 subsections\n  - class SpooledTemporaryFile (77 lines)\n  - class TemporaryDirectory (43 lines)\n- **FUNCTIONS** (30 lines) — 7 subsections\n  - gettempdir (2 lines)\n  - gettempdirb (2 lines)\n  - gettempprefix (2 lines)\n  - gettempprefixb (2 lines)\n  - mkdtemp (11 lines)\n  - mkstemp (27 lines)\n  - mktemp (12 lines)\n- **DATA** (4 lines)\n- **FILE** (3 lines)\n\n## Full Content\n\n### NAME\n\ntempfile - Temporary files.\n\n### MODULE REFERENCE\n\nhttps://docs.python.org/3.10/library/tempfile.html\n\nThe following documentation is automatically generated from the Python\nsource files.  It may be incomplete, incorrect or include features that\nare considered implementation detail and may vary between Python\nimplementations.  When in doubt, consult the module reference at the\nlocation listed above.\n\n### DESCRIPTION\n\nThis module provides generic, low- and high-level interfaces for\ncreating temporary files and directories.  All of the interfaces\nprovided by this module can be used without fear of race conditions\nexcept for 'mktemp'.  'mktemp' is subject to race conditions and\nshould not be used; it is provided for backward compatibility only.\n\nThe default path names are returned as str.  If you supply bytes as\ninput, all return values will be in bytes.  Ex:\n\n>>> tempfile.mkstemp()\n(4, '/tmp/tmptpu9nin8')\n>>> tempfile.mkdtemp(suffix=b'')\nb'/tmp/tmppbi8f0hy'\n\nThis module also provides some data items to the user:\n\nTMPMAX  - maximum number of names that will be tried before\ngiving up.\ntempdir  - If this is set to a string before the first use of\nany routine from this module, it will be considered as\nanother candidate location to store temporary files.\n\n### CLASSES\n\nbuiltins.object\nSpooledTemporaryFile\nTemporaryDirectory\n\n#### class SpooledTemporaryFile\n\n|  SpooledTemporaryFile(maxsize=0, mode='w+b', buffering=-1, encoding=None, newline=None, suffix=None, prefix=None, dir=None, *, errors=None)\n|\n|  Temporary file wrapper, specialized to switch from BytesIO\n|  or StringIO to a real file when it exceeds a certain size or\n|  when a fileno is needed.\n|\n|  Methods defined here:\n|\n|  enter(self)\n|      # Context management protocol\n|\n|  exit(self, exc, value, tb)\n|\n|  init(self, maxsize=0, mode='w+b', buffering=-1, encoding=None, newline=None, suffix=None, prefix=None, dir=None, *, errors=None)\n|      Initialize self.  See help(type(self)) for accurate signature.\n|\n|  iter(self)\n|      # file protocol\n|\n|  close(self)\n|\n|  fileno(self)\n|\n|  flush(self)\n|\n|  isatty(self)\n|\n|  read(self, *args)\n|\n|  readline(self, *args)\n|\n|  readlines(self, *args)\n|\n|  rollover(self)\n|\n|  seek(self, *args)\n|\n|  tell(self)\n|\n|  truncate(self, size=None)\n|\n|  write(self, s)\n|\n|  writelines(self, iterable)\n|\n|  ----------------------------------------------------------------------\n|  Class methods defined here:\n|\n|  classgetitem = GenericAlias(...) from builtins.type\n|      Represent a PEP 585 generic type\n|\n|      E.g. for t = list[int], t.origin is list and t.args is (int,).\n|\n|  ----------------------------------------------------------------------\n|  Readonly properties defined here:\n|\n|  closed\n|\n|  encoding\n|\n|  errors\n|\n|  mode\n|\n|  name\n|\n|  newlines\n|\n|  ----------------------------------------------------------------------\n|  Data descriptors defined here:\n|\n|  dict\n|      dictionary for instance variables (if defined)\n|\n|  weakref\n|      list of weak references to the object (if defined)\n\n#### class TemporaryDirectory\n\n|  TemporaryDirectory(suffix=None, prefix=None, dir=None, ignorecleanuperrors=False)\n|\n|  Create and return a temporary directory.  This has the same\n|  behavior as mkdtemp but can be used as a context manager.  For\n|  example:\n|\n|      with TemporaryDirectory() as tmpdir:\n|          ...\n|\n|  Upon exiting the context, the directory and everything contained\n|  in it are removed.\n|\n|  Methods defined here:\n|\n|  enter(self)\n|\n|  exit(self, exc, value, tb)\n|\n|  init(self, suffix=None, prefix=None, dir=None, ignorecleanuperrors=False)\n|      Initialize self.  See help(type(self)) for accurate signature.\n|\n|  repr(self)\n|      Return repr(self).\n|\n|  cleanup(self)\n|\n|  ----------------------------------------------------------------------\n|  Class methods defined here:\n|\n|  classgetitem = GenericAlias(...) from builtins.type\n|      Represent a PEP 585 generic type\n|\n|      E.g. for t = list[int], t.origin is list and t.args is (int,).\n|\n|  ----------------------------------------------------------------------\n|  Data descriptors defined here:\n|\n|  dict\n|      dictionary for instance variables (if defined)\n|\n|  weakref\n|      list of weak references to the object (if defined)\n\n### FUNCTIONS\n\nNamedTemporaryFile(mode='w+b', buffering=-1, encoding=None, newline=None, suffix=None, prefix=None, dir=None, delete=True, *, errors=None)\nCreate and return a temporary file.\nArguments:\n'prefix', 'suffix', 'dir' -- as for mkstemp.\n'mode' -- the mode argument to io.open (default \"w+b\").\n'buffering' -- the buffer size argument to io.open (default -1).\n'encoding' -- the encoding argument to io.open (default None)\n'newline' -- the newline argument to io.open (default None)\n'delete' -- whether the file is deleted on close (default True).\n'errors' -- the errors argument to io.open (default None)\nThe file is created as mkstemp() would do it.\n\nReturns an object with a file-like interface; the name of the file\nis accessible as its 'name' attribute.  The file will be automatically\ndeleted when it is closed unless the 'delete' argument is set to False.\n\nTemporaryFile(mode='w+b', buffering=-1, encoding=None, newline=None, suffix=None, prefix=None, dir=None, *, errors=None)\nCreate and return a temporary file.\nArguments:\n'prefix', 'suffix', 'dir' -- as for mkstemp.\n'mode' -- the mode argument to io.open (default \"w+b\").\n'buffering' -- the buffer size argument to io.open (default -1).\n'encoding' -- the encoding argument to io.open (default None)\n'newline' -- the newline argument to io.open (default None)\n'errors' -- the errors argument to io.open (default None)\nThe file is created as mkstemp() would do it.\n\nReturns an object with a file-like interface.  The file has no\nname, and will cease to exist when it is closed.\n\n#### gettempdir\n\nReturns tempfile.tempdir as str.\n\n#### gettempdirb\n\nReturns tempfile.tempdir as bytes.\n\n#### gettempprefix\n\nThe default prefix for temporary directories as string.\n\n#### gettempprefixb\n\nThe default prefix for temporary directories as bytes.\n\n#### mkdtemp\n\nUser-callable function to create and return a unique temporary\ndirectory.  The return value is the pathname of the directory.\n\nArguments are as for mkstemp, except that the 'text' argument is\nnot accepted.\n\nThe directory is readable, writable, and searchable only by the\ncreating user.\n\nCaller is responsible for deleting the directory when done with it.\n\n#### mkstemp\n\nUser-callable function to create and return a unique temporary\nfile.  The return value is a pair (fd, name) where fd is the\nfile descriptor returned by os.open, and name is the filename.\n\nIf 'suffix' is not None, the file name will end with that suffix,\notherwise there will be no suffix.\n\nIf 'prefix' is not None, the file name will begin with that prefix,\notherwise a default prefix is used.\n\nIf 'dir' is not None, the file will be created in that directory,\notherwise a default directory is used.\n\nIf 'text' is specified and true, the file is opened in text\nmode.  Else (the default) the file is opened in binary mode.\n\nIf any of 'suffix', 'prefix' and 'dir' are not None, they must be the\nsame type.  If they are bytes, the returned name will be bytes; str\notherwise.\n\nThe file is readable and writable only by the creating user ID.\nIf the operating system uses permission bits to indicate whether a\nfile is executable, the file is executable by no one. The file\ndescriptor is not inherited by children of this process.\n\nCaller is responsible for deleting the file when done with it.\n\n#### mktemp\n\nUser-callable function to return a unique temporary file name.  The\nfile is not created.\n\nArguments are similar to mkstemp, except that the 'text' argument is\nnot accepted, and suffix=None, prefix=None and bytes file names are not\nsupported.\n\nTHIS FUNCTION IS UNSAFE AND SHOULD NOT BE USED.  The file name may\nrefer to a file that did not exist at some point, but by the time\nyou get around to creating it, someone else may have beaten you to\nthe punch.\n\n### DATA\n\nTMPMAX = 238328\nall = ['NamedTemporaryFile', 'TemporaryFile', 'SpooledTemporaryFil...\ntempdir = None\n\n### FILE\n\n/usr/lib/python3.10/tempfile.py\n\n"
        }
    ],
    "structuredContent": {
        "command": "tempfile",
        "section": "",
        "mode": "pydoc",
        "summary": "tempfile - Temporary files.",
        "synopsis": null,
        "tldr_summary": null,
        "tldr_examples": [],
        "tldr_source": null,
        "flags": [],
        "examples": [],
        "see_also": [],
        "section_outline": [
            {
                "name": "NAME",
                "lines": 2,
                "subsections": []
            },
            {
                "name": "MODULE REFERENCE",
                "lines": 8,
                "subsections": []
            },
            {
                "name": "DESCRIPTION",
                "lines": 22,
                "subsections": []
            },
            {
                "name": "CLASSES",
                "lines": 4,
                "subsections": [
                    {
                        "name": "class SpooledTemporaryFile",
                        "lines": 77
                    },
                    {
                        "name": "class TemporaryDirectory",
                        "lines": 43
                    }
                ]
            },
            {
                "name": "FUNCTIONS",
                "lines": 30,
                "subsections": [
                    {
                        "name": "gettempdir",
                        "lines": 2
                    },
                    {
                        "name": "gettempdirb",
                        "lines": 2
                    },
                    {
                        "name": "gettempprefix",
                        "lines": 2
                    },
                    {
                        "name": "gettempprefixb",
                        "lines": 2
                    },
                    {
                        "name": "mkdtemp",
                        "lines": 11
                    },
                    {
                        "name": "mkstemp",
                        "lines": 27
                    },
                    {
                        "name": "mktemp",
                        "lines": 12
                    }
                ]
            },
            {
                "name": "DATA",
                "lines": 4,
                "subsections": []
            },
            {
                "name": "FILE",
                "lines": 3,
                "subsections": []
            }
        ]
    }
}