473,322 Members | 1,241 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

How to detect if file is a directory

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
2 2991
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Doug R | last post by:
Hello, I could use a little help from you Gurus out there. I have an aplication that watches a directory and detects when a PGP encrypted file lands in the directory and starts a process that...
8
by: Claudio Grondi | last post by:
It is maybe not a pure Python question, but I think it is the right newsgroup to ask for help, anyway. After connecting a drive to the system (via USB or IDE) I would like to be able to see...
1
by: Antonio Maciel | last post by:
Hi. My application uses 4 xml files as configuration files. Actually, I use an If statement with a function to run my schema files against the xml files every time the application loads. This...
4
by: Jim Renton | last post by:
Hi everyone How do you detect if directory exist and if it doesn’t how do you create one Thank Ji
2
by: eBob.com | last post by:
I've got the basics of an XML ini file working. I.E. I can stash away and retrieve user preferences. (Code below.) But how do I handle a new preference? Say I have A and B. And then I invent...
5
by: Lukas Meyer | last post by:
Hello, I'm trying to detect changes in a directory. E.g if someone crates a file, i'll execute another function on this file. I tried to solve this by creating a loop that permanently checks...
3
by: Asterbing | last post by:
Since the "on fly addition..." thread has taken another direction, I'm opening a new one to be more explicit and recenter the subject. Well, the subject is to detect when a document is well...
32
by: Olivier | last post by:
Dear all, I thought the code ----------------------------- pt_fichier_probleme = fopen(nom_fichier, "w"); if(pt_fichier_probleme == NULL){ message_warning_s ("Erreur l'ouverture du...
4
by: ThatsIT.net.au | last post by:
Is it possible to detect the build config via code. I want to run a program with a different connection string when in debug config any ideas?
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shćllîpôpď 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.