Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[doc] State clearly that open() 'file' param is "name" attr of the result#142694

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
GrigoriiKashchenko wants to merge2 commits intopython:main
base:main
Choose a base branch
Loading
fromGrigoriiKashchenko:doc-open-name-attr
Open
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletionsDoc/library/functions.rst
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -1494,6 +1494,12 @@ are always available. They are listed here in alphabetical order.
disabled, the raw stream, a subclass of :class:`io.RawIOBase`,
:class:`io.FileIO`, is returned.

The *file* argument is saved as the :attr:`~io.IOBase.name` attribute of
the returned file object. If *file* is given as a string or bytes object,
it will be saved as-is. If it is given as an integer file descriptor,
the :attr:`~io.IOBase.name` attribute will contain the file descriptor value.
For other object types, the representation of the object will be stored.

.. index::
single: line-buffered I/O
single: unbuffered I/O
Expand DownExpand Up@@ -1540,6 +1546,10 @@ are always available. They are listed here in alphabetical order.
.. versionchanged:: 3.11
The ``'U'`` mode has been removed.

.. versionchanged:: 3.13
Clarified that the *file* argument is saved as the :attr:`~io.IOBase.name`
attribute.

.. function:: ord(character, /)

Return the ordinal value of a character.
Expand Down
15 changes: 13 additions & 2 deletionsDoc/library/io.rst
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -363,6 +363,14 @@ I/O Base Classes
As a convenience, it is allowed to call this method more than once;
only the first call, however, will have an effect.

.. attribute:: name

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

.. attribute:: closed

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

.. attribute:: name

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


Buffered Streams
Expand Down
Loading

[8]ページ先頭

©2009-2026 Movatter.jp