[clug] Python Golf time

Andrew Janke a.janke at gmail.com
Fri Apr 8 01:25:01 UTC 2016


Yes, Python.  I'm being forced off Perl.


Shortest way to find the first file in a directory tree.

Bonus points for finding a file of a specific mime type.  Everything
I've tried uses os.walk or is like this:

    for f in os.listdir(directory):
        if f.endswith(".txt"):
            winner = f
            break

(the above of course only deals with one directory level)


a



More information about the linux mailing list