Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
59fe937c
Commit
59fe937c
authored
Jan 31, 2016
by
Victor Stinner
Browse files
Options
Browse Files
Download
Plain Diff
Merge 3.5 (doc)
parents
ce5179fc
5f0c5d92
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
38 additions
and
35 deletions
+38
-35
Doc/library/os.rst
Doc/library/os.rst
+38
-35
No files found.
Doc/library/os.rst
View file @
59fe937c
...
@@ -1960,62 +1960,65 @@ features:
...
@@ -1960,62 +1960,65 @@ features:
Return the inode number of the entry.
Return the inode number of the entry.
The result is cached on the ``DirEntry`` object
, u
se ``os.stat(entry.path,
The result is cached on the ``DirEntry`` object
. U
se ``os.stat(entry.path,
follow_symlinks=False).st_ino`` to fetch up-to-date information.
follow_symlinks=False).st_ino`` to fetch up-to-date information.
On Unix, no system call is required.
On the first, uncached call, a system call is required on Windows but
not on Unix.
.. method:: is_dir(\*, follow_symlinks=True)
.. method:: is_dir(\*, follow_symlinks=True)
If *follow_symlinks* is ``True`` (the default), return ``True`` if the
Return ``True`` if this entry is a directory or a symbolic link pointing
entry is a directory or a symbolic link pointing to a directory;
to a directory; return ``False`` if the entry is or points to any other
return ``False`` if it is or points to any other kind of file, or if it
kind of file, or if it doesn't exist anymore.
doesn't exist anymore.
If *follow_symlinks* is ``False``, return ``True`` only if this entry
If *follow_symlinks* is ``False``, return ``True`` only if this entry
is a directory; return ``False`` if it is any other kind of file
is a directory (without following symlinks); return ``False`` if the
or if it doesn't exist anymore.
entry is any other kind of file or if it doesn't exist anymore.
The result is cached on the ``DirEntry`` object, with a separate cache
for *follow_symlinks* ``True`` and ``False``. Call :func:`os.stat` along
with :func:`stat.S_ISDIR` to fetch up-to-date information.
The result is cached on the ``DirEntry`` object. Call :func:`os.stat`
On the first, uncached call, no system call is required in most cases.
along with :func:`stat.S_ISDIR` to fetch up-to-date information.
Specifically, for non-symlinks, neither Windows or Unix require a system
call, except on certain Unix file systems, such as network file systems,
that return ``dirent.d_type == DT_UNKNOWN``. If the entry is a symlink,
a system call will be required to follow the symlink unless
*follow_symlinks* is ``False``.
This method can raise :exc:`OSError`, such as :exc:`PermissionError`,
This method can raise :exc:`OSError`, such as :exc:`PermissionError`,
but :exc:`FileNotFoundError` is caught and not raised.
but :exc:`FileNotFoundError` is caught and not raised.
In most cases, no system call is required.
.. method:: is_file(\*, follow_symlinks=True)
.. method:: is_file(\*, follow_symlinks=True)
If *follow_symlinks* is ``True`` (the default), return ``True`` if the
Return ``True`` if this entry is a file or a symbolic link pointing to a
entry is a file or a symbolic link pointing to a file; return ``False``
file; return ``False`` if the entry is or points to a directory or other
if it is or points to a directory or other non-file entry, or if it
non-file entry, or if it doesn't exist anymore.
doesn't exist anymore.
If *follow_symlinks* is ``False``, return ``True`` only if this entry
If *follow_symlinks* is ``False``, return ``True`` only if this entry
is a file
; return ``False`` if it is a directory or other non-file entry,
is a file
(without following symlinks); return ``False`` if the entry is
or if it doesn't exist anymore.
a directory or other non-file entry,
or if it doesn't exist anymore.
The result is cached on the ``DirEntry`` object. Call :func:`os.stat`
The result is cached on the ``DirEntry`` object. Caching, system calls
along with :func:`stat.S_ISREG` to fetch up-to-date information.
made, and exceptions raised are as per :func:`~DirEntry.is_dir`.
This method can raise :exc:`OSError`, such as :exc:`PermissionError`,
but :exc:`FileNotFoundError` is caught and not raised.
In most cases, no system call is required.
.. method:: is_symlink()
.. method:: is_symlink()
Return ``True`` if this entry is a symbolic link (even if broken);
Return ``True`` if this entry is a symbolic link (even if broken);
return ``False`` if
it
points to a directory or any kind of file,
return ``False`` if
the entry
points to a directory or any kind of file,
or if it doesn't exist anymore.
or if it doesn't exist anymore.
The result is cached on the ``DirEntry`` object. Call
The result is cached on the ``DirEntry`` object. Call
:func:`os.path.islink` to fetch up-to-date information.
:func:`os.path.islink` to fetch up-to-date information.
The method can raise :exc:`OSError`, such as :exc:`PermissionError`,
On the first, uncached call, no system call is required in most cases.
but :exc:`FileNotFoundError` is caught and not raised.
Specifically, neither Windows or Unix require a system call, except on
certain Unix file systems, such as network file systems, that return
``dirent.d_type == DT_UNKNOWN``.
In most cases, no system call is required.
This method can raise :exc:`OSError`, such as :exc:`PermissionError`,
but :exc:`FileNotFoundError` is caught and not raised.
.. method:: stat(\*, follow_symlinks=True)
.. method:: stat(\*, follow_symlinks=True)
...
@@ -2023,17 +2026,17 @@ features:
...
@@ -2023,17 +2026,17 @@ features:
follows symbolic links by default; to stat a symbolic link add the
follows symbolic links by default; to stat a symbolic link add the
``follow_symlinks=False`` argument.
``follow_symlinks=False`` argument.
On Unix, this method always requires a system call. On Windows,
On Unix, this method always requires a system call. On Windows, it
``DirEntry.stat()`` requires a system call only if the
only requires a system call if *follow_symlinks* is ``True`` and the
entry is a symbolic link, and ``DirEntry.stat(follow_symlinks=False)``
entry is a symbolic link.
never requires a system call.
On Windows, the ``st_ino``, ``st_dev`` and ``st_nlink`` attributes of the
On Windows, the ``st_ino``, ``st_dev`` and ``st_nlink`` attributes of the
:class:`stat_result` are always set to zero. Call :func:`os.stat` to
:class:`stat_result` are always set to zero. Call :func:`os.stat` to
get these attributes.
get these attributes.
The result is cached on the ``DirEntry`` object. Call :func:`os.stat`
The result is cached on the ``DirEntry`` object, with a separate cache
to fetch up-to-date information.
for *follow_symlinks* ``True`` and ``False``. Call :func:`os.stat` to
fetch up-to-date information.
Note that there is a nice correspondence between several attributes
Note that there is a nice correspondence between several attributes
and methods of ``DirEntry`` and of :class:`pathlib.Path`. In
and methods of ``DirEntry`` and of :class:`pathlib.Path`. In
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment