This documentation covers a development version of IPython. The development version may differ significantly from the latest stable release.
This documentation covers IPython versions 6.0 and higher. Beginning with version 6.0, IPython stopped supporting compatibility with Python versions lower than 3.3 including all versions of Python 2.7.
If you are looking for an IPython version compatible with Python 2.7, please use the IPython 5.x LTS release and refer to its documentation (LTS is the long term support release).
This module contains classes - NamedFileInTemporaryDirectory, TemporaryWorkingDirectory.
These classes add extra features such as creating a named file in temporary directory and creating a context manager for the working directory which is also temporary.
NamedFileInTemporaryDirectory(filename, mode='w+b', bufsize=- 1, **kwds)¶
__init__(filename, mode='w+b', bufsize=- 1, **kwds)¶
Open a file named
filenamein a temporary directory.
This context manager is preferred over
tempfilewhen one needs to reopen the file.
bufsizeare passed to
open. Rest of the arguments are passed to
TemporaryWorkingDirectory(suffix=None, prefix=None, dir=None)¶
Creates a temporary directory and sets the cwd to that directory. Automatically reverts to previous cwd upon cleanup. Usage example:
- with TemporaryWorkingDirectory() as tmpdir: