470,614 Members | 1,396 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,614 developers. It's quick & easy.

How to check if a directory is exist in python?

I check the documentation here, but it does not say how to check if a
directory is exist in python?
http://docs.python.org/lib/os-file-dir.html

And why mkdir fails if the directory already exists?

Thank you.

Mar 19 '06 #1
4 29417
Check out os.path.isdir(path_name)

http://docs.python.org/lib/module-os.path.html

Mar 19 '06 #2
<yi*****@gmail.com> wrote in message
news:11*********************@j33g2000cwa.googlegro ups.com...
|I check the documentation here, but it does not say how to check if a
| directory is exist in python?
| http://docs.python.org/lib/os-file-dir.html

Look at the exist or isdir methods of the os.path module
(http://docs.python.org/lib/module-os.path.html}

|
| And why mkdir fails if the directory already exists?

If you prefer a "more friendly" approach you may wanna take a look at Trent
Mick's _mkdir which is located at
http://aspn.activestate.com/ASPN/Coo...n/Recipe/82465
|

Regards,
Vincent Wehren

| Thank you.
|
Mar 19 '06 #3
"Vincent Wehren" <vi*****@visualtrans.de> wrote in message
news:dv**********@news4.tilbu1.nb.home.nl...
| <yi*****@gmail.com> wrote in message
| news:11*********************@j33g2000cwa.googlegro ups.com...
||I check the documentation here, but it does not say how to check if a
|| directory is exist in python?
|| http://docs.python.org/lib/os-file-dir.html
|
| Look at the exist or isdir methods of the os.path module

Ofcourse I mean "exists"...

| (http://docs.python.org/lib/module-os.path.html}
|
||
|| And why mkdir fails if the directory already exists?
|
| If you prefer a "more friendly" approach you may wanna take a look at
Trent
| Mick's _mkdir which is located at
| http://aspn.activestate.com/ASPN/Coo...n/Recipe/82465
||
|
| Regards,
| Vincent Wehren
|
|| Thank you.
||
|
|
Mar 19 '06 #4
Vincent Wehren wrote:
| <yi*****@gmail.com> wrote in message
| news:11*********************@j33g2000cwa.googlegro ups.com...
||I check the documentation here, but it does not say how to check if a
|| directory is exist in python?
|| http://docs.python.org/lib/os-file-dir.html
|
| Look at the exist or isdir methods of the os.path module

Ofcourse I mean "exists"...

You also mean "functions", not "methods". *Classes* have methods.

regards
Steve
--
Steve Holden +44 150 684 7255 +1 800 494 3119
Holden Web LLC/Ltd www.holdenweb.com
Love me, love my blog holdenweb.blogspot.com

Mar 19 '06 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by build | last post: by
2 posts views Thread by David Fickbohm | last post: by
19 posts views Thread by SU News Server | last post: by
6 posts views Thread by hectorlas | last post: by
14 posts views Thread by John Salerno | last post: by
reply views Thread by Alan Meyer | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.