[Tutor] Howto test if something is a directory?

Corran Webster cwebster@nevada.edu
Sun, 23 Jan 2000 11:57:03 -0800 (PST)


On Sun, 23 Jan 2000, Neil Conway <Neil Conway wrote:
> 
> I want to take the output of os.listdir() and test each entry to see
> if it is a directory, or a regular file. What is the best way to do
> this? 
> 
> I would prefer a method that works on Windows, Mac and UNIX, but if it
> is OS-dependant, UNIX is by far the most important.
> 
> Sorry if this is in the standard documentation, I couldn't find it.
> 
> Thanks in advance,,

I think you want the routines in os.path, such as os.path.isdir() and
os.path.isfile().

You don't say what you want to use the info for, but if you are trying to
walk a directory tree, look at os.path.walk().

Regarsd,
Corran