Hi!

On Tue, May 08, 2018 at 07:12:35AM +0000, Yuval Greenfield 
<ubershme...@gmail.com> wrote:
> If you
> want to avoid duplicate `stat` calls, you'll probably write:
> 
> import os
> import stat
> def is_hidden(st):
>     return bool(st.st_file_attributes & stat.FILE_ATTRIBUTE_HIDDEN)
> def visible_walk(path):
>     for entry in os.scandir(path):
>         if entry.is_dir():
>             if not is_hidden(entry.stat()):
>                 yield from visible_walk(entry.path)
>         else:
>             if not is_hidden(entry.stat()):
>                 yield entry.path

   So anyone who wants to filter os.walk() must reimplement os.walk()
themselves instead of passing something like filter_dir and filter_file
(or accept_dir/accept_file) to os.walk()? Kind of painful, no?

> Cheers,
> Yuval

Oleg.
-- 
     Oleg Broytman            http://phdru.name/            p...@phdru.name
           Programmers don't die, they just GOSUB without RETURN.
_______________________________________________
Python-ideas mailing list
Python-ideas@python.org
https://mail.python.org/mailman/listinfo/python-ideas
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to