Partial directory search question

Martien Verbruggen martien.verbruggen at invalid.see.sig
Wed Sep 30 00:21:43 EDT 2009


On Tue, 29 Sep 2009 19:09:16 -0700 (PDT),
	chad <cdalten at gmail.com> wrote:
> I have a directory that contains the following
>
> login
> rc
> sum
> _1
> _2
> _3
> _4
>
> 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 don't know what you mean by "sanest", but this is one way:

import glob
for f in glob.glob("_*"):
    print f

Martien
-- 
                             | 
Martien Verbruggen           | You can't have everything, where would
first.last at heliotrope.com.au | you put it?
                             | 



More information about the Python-list mailing list