How to detect if file is a directory

  • Thread starter =?ISO-8859-1?Q?C=E9sar_Leonardo_Blum_Silveira?=
  • Start date
?

=?ISO-8859-1?Q?C=E9sar_Leonardo_Blum_Silveira?=

Hello all, I'm new to this list.

How can I detect if a file is a directory or not?

Thanks

César
 
T

Tim Jarman

César Leonardo Blum Silveira said:
Hello all, I'm new to this list.

How can I detect if a file is a directory or not?

Thanks

César

The os module contains many helpful tools for working with files,
directories, links and so forth. Check out the docs and marvel. The
following snippet answers your specific question:

<code>
import os.path

if os.path.isdir("/some/path/here"):
print "It's a directory!"
</code>
 
?

=?ISO-8859-1?Q?C=E9sar_Leonardo_Blum_Silveira?=

Thanks :)

The os module contains many helpful tools for working with files,
directories, links and so forth. Check out the docs and marvel. The
following snippet answers your specific question:

<code>
import os.path

if os.path.isdir("/some/path/here"):
print "It's a directory!"
</code>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,234
Messages
2,571,178
Members
47,809
Latest member
Adisty

Latest Threads

Top