Skip to content

Commit f9ffa60

Browse files
[doc] Update io.rst documentation for name attribute
Clarify FileIO.name and IOBase.name documentation to match functions.rst
1 parent 7e22940 commit f9ffa60

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

Doc/library/io.rst

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -363,6 +363,14 @@ I/O Base Classes
363363
As a convenience, it is allowed to call this method more than once;
364364
only the first call, however, will have an effect.
365365

366+
.. attribute:: name
367+
368+
The name of the underlying file if it has one.
369+
This is the *file* argument as passed to :func:`open` or the constructor.
370+
The type of this attribute depends on what was originally passed - it may
371+
be a string, bytes, integer file descriptor, or other object representation.
372+
If there is no underlying file, the attribute may be ``None``.
373+
366374
.. attribute:: closed
367375

368376
``True`` if the stream is closed.
@@ -700,8 +708,11 @@ Raw File I/O
700708

701709
.. attribute:: name
702710

703-
The file name. This is the file descriptor of the file when no name is
704-
given in the constructor.
711+
The file name. This is the *name* argument as passed to the constructor.
712+
Depending on the type of object that was passed, this may be a string,
713+
bytes, integer file descriptor, or other object representation.
714+
If the file was opened using a file descriptor, the *name* attribute
715+
will contain the file descriptor value.
705716

706717

707718
Buffered Streams

0 commit comments

Comments
 (0)