Mailing List Archive

glob and directory
Hello.

I would like each output of "glob.glob()" to be
added "/"
if returned value is directory.

That is...

>>> import glob
>>> print glob.glob('*')
['file1', 'file2', 'file3', 'dir1', 'dir2']

===> ['file1', 'file2', 'file3', 'dir1/', 'dir2/']

Is it possible ?

If not, is there any way to determine
if the given name is directory or not ?

Thanks for reading.

Thooney Millennier.
glob and directory [ In reply to ]
too@pk.highway.ne.jp wrote:

> is there any way to determine
> if the given name is directory or not ?

os.path.isdir

If you're just globbing '*', then you could also use

os.listdir('.')

It'll save you from having to type "import glob". :)

-------------------------------------------
Tom Bryan
Applied Research Laboratories
University of Texas at Austin