[Python-Dev] Issue 11406: adding os.scandir(), a directory iterator returning stat-like info (original) (raw)
Ronald Oussoren ronaldoussoren at mac.com
Fri May 10 16:42:49 CEST 2013
- Previous message: [Python-Dev] Issue 11406: adding os.scandir(), a directory iterator returning stat-like info
- Next message: [Python-Dev] Issue 11406: adding os.scandir(), a directory iterator returning stat-like info
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On 10 May, 2013, at 16:30, MRAB <python at mrabarnett.plus.com> wrote:
[snip] In the python-ideas list there's a thread "PEP: Extended statresult" about adding methods to statresult. Using that, you wouldn't necessarily have to look at st.stmode. The method could perform an additional os.stat() if the field was None. For example: # Build lists of files and directories in path files = [] dirs = [] for name, st in os.scandir(path): if st.isdir(): dirs.append(name) else: files.append(name) That looks much nicer.
I'd prefer a filetype field, with 'st.filetype == "dir"' instead of 'st.is_dir()'. The actual type of filetype values is less important, an enum type would also work although bootstrapping that type could be interesting.
Ronald
Python-Dev mailing list Python-Dev at python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/ronaldoussoren%40mac.com
- Previous message: [Python-Dev] Issue 11406: adding os.scandir(), a directory iterator returning stat-like info
- Next message: [Python-Dev] Issue 11406: adding os.scandir(), a directory iterator returning stat-like info
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]