Re: Searching for a file

Chris Angelico via Python-list <[email protected]>
Newsgroups gmane.comp.python.general
Message-ID <CAPTjJmrWCEG1adWRU4SB6Upz9ASOss1vHjPd3vXpuGxAJT-5tA@mail.gmail.com>
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.

ChrisA
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.