By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,587 Members | 1,677 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,587 IT Pros & Developers. It's quick & easy.

How to detect if file is a directory

P: n/a
Hello all, I'm new to this list.

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

Thanks

César
Jul 18 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
César Leonardo Blum Silveira wrote:
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>
--
Website: www DOT jarmania FULLSTOP com
Jul 18 '05 #2

P: n/a
Thanks :-)

On Apr 9, 2005 3:55 PM, Tim Jarman <tm*@spamlessjarmania.com> wrote:
César Leonardo Blum Silveira wrote:
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>
--
Website: www DOT jarmania FULLSTOP com
--
http://mail.python.org/mailman/listinfo/python-list

Jul 18 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.