Re: Searching for a file
Grant Edwards via Python-list <[email protected]>
| Newsgroups | gmane.comp.python.general |
|---|---|
| Message-ID | <[email protected]> |
On 2025-08-05, Michael Torrie via Python-list <[email protected]> wrote: > On 5/24/25 7:19 PM, Chris Angelico via Python-list wrote: >> On Sun, 25 May 2025 at 10:05, Rob Cliffe via Python-list >> <[email protected]> wrote: >>> Yes, but if I understand correctly, they all start from a single >>> directory (and work downwards if required). >>> My suggestion involved searching a *list* (possibly multiple lists) of >>> directories. >> >> for dir in dirs: >> try: open(dir + "/" + fn).close() >> except FileNotFoundError: pass >> else: break >> >> Is this really all that difficult? Not everything has to be in the stdlib. > > That would modify atime on unix file systems, no? Of course most modern > file systems on SSDs are mounted with noatime, but still. Why not call os.stat() instead of open/close? Maybe that's already been suggested. I forget -- this is a pretty old thread.