Skip to content

Commit 2368607

Browse files
committed
#14515: clarify that TemporaryDirectory's __enter__ returns the name.
1 parent 3b4f159 commit 2368607

1 file changed

Lines changed: 6 additions & 4 deletions

File tree

Doc/library/tempfile.rst

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -97,12 +97,14 @@ The module defines the following user-callable items:
9797
This function creates a temporary directory using :func:`mkdtemp`
9898
(the supplied arguments are passed directly to the underlying function).
9999
The resulting object can be used as a context manager (see
100-
:ref:`context-managers`). On completion of the context (or destruction
101-
of the temporary directory object), the newly created temporary directory
100+
:ref:`context-managers`). On completion of the context or destruction
101+
of the temporary directory object the newly created temporary directory
102102
and all its contents are removed from the filesystem.
103103

104-
The directory name can be retrieved from the :attr:`name` attribute
105-
of the returned object.
104+
The directory name can be retrieved from the :attr:`name` attribute of the
105+
returned object. When the returned object is used as a context manager, the
106+
:attr:`name` will be assigned to the target of the :keyword:`as` clause in
107+
the :keyword:`with` statement, if there is one.
106108

107109
The directory can be explicitly cleaned up by calling the
108110
:func:`cleanup` method.

0 commit comments

Comments
 (0)