diff options
author | Larry Hastings <larry@hastings.org> | 2012-06-25 11:42:23 (GMT) |
---|---|---|
committer | Larry Hastings <larry@hastings.org> | 2012-06-25 11:42:23 (GMT) |
commit | fdaea06d3c0a020c226f26114aad4e58688f0ab3 (patch) | |
tree | b1aa85122d0fe1eb4c706d6e129215f69555ffff /Doc/library/os.rst | |
parent | 3b52778c74f0290e6103a6381ff9189f6b8c5e51 (diff) | |
download | cpython-fdaea06d3c0a020c226f26114aad4e58688f0ab3.zip cpython-fdaea06d3c0a020c226f26114aad4e58688f0ab3.tar.gz cpython-fdaea06d3c0a020c226f26114aad4e58688f0ab3.tar.bz2 |
Issue #15176: Clarified behavior, documentation, and implementation
of os.listdir().
Diffstat (limited to 'Doc/library/os.rst')
-rw-r--r-- | Doc/library/os.rst | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/Doc/library/os.rst b/Doc/library/os.rst index bc0d69d..0b6ab24 100644 --- a/Doc/library/os.rst +++ b/Doc/library/os.rst @@ -1488,16 +1488,19 @@ features: .. function:: listdir(path='.') Return a list containing the names of the entries in the directory given by - *path* (default: ``'.'``). The list is in arbitrary order. It does not - include the special entries ``'.'`` and ``'..'`` even if they are present in - the directory. + *path*. The list is in arbitrary order, and does not include the special + entries ``'.'`` and ``'..'`` even if they are present in the directory. - This function can be called with a bytes or string argument, and returns - filenames of the same datatype. + *path* may be either of type ``str`` or of type ``bytes``. If *path* + is of type ``bytes``, the filenames returned will also be of type ``bytes``; + in all other circumstances, they will be of type ``str``. This function can also support :ref:`specifying a file descriptor <path_fd>`; the file descriptor must refer to a directory. + .. note:: + To encode ``str`` filenames to ``bytes``, use :func:`~os.fsencode`. + Availability: Unix, Windows. .. versionchanged:: 3.2 |