[issue44198] Add flags or function in pathlib.Path

2021-05-21 Thread Barney Gale


Barney Gale  added the comment:

My view:

I think the existing solution (that you highlight) is sufficiently idiomatic 
and easy to discover, and doesn't warrant a new argument or function.

However, that may change when `Path` is subclassable, for two reasons:

1. You will be able to subclass `Path` and add your own method, which you may 
find preferable to a helper function.
2. We _may_ add some sort of file type enum that wraps the constants in `stat`. 
In that case it might be natural to add a `file_type` argument to `iterdir()`. 
No promises!

--
nosy: +barneygale

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue44198] Add flags or function in pathlib.Path

2021-05-20 Thread Mikhail


New submission from Mikhail :

Hello! This is a very useful feature when a Path-object gets a list (or 
generator, as it is now) of files/dirs in self.dir, I think. Right now this is 
the .iterdir() function, but sometimes you only need `dirs` of that path (for 
example, I really needed the function when I was working with images for 
classification), and at the moment this is only solved by (path for path in 
root.iterdir() if path.is_dir()). You could make separate functions for this, 
but I suggest just adding the only_dirs/only_files(/only_links) flags to 
.iterdir().

--
components: Library (Lib)
messages: 394064
nosy: tetelevm
priority: normal
severity: normal
status: open
title: Add flags or function in pathlib.Path
versions: Python 3.10

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com