Partial directory search question
Tim Chase
python.list at tim.thechases.com
Tue Sep 29 22:20:46 EDT 2009
> What's the sanest way to print out all the files in the directory that
> start with the underscore? Ie, I just want to list _1, _2, _3, _4.
I'd use a string's join() method to combine the results of a
list-comprehension or generator that filtered the output of
os.listdir() based on the startswith() method of the strings.
Left intentionally oblique and code-free because this sounds a
bit like a home-work problem. If you're a python coder, that
should make pretty decent sense and be a one-liner to implement.
-tkc
More information about the Python-list
mailing list