0

Hi , I have a question ..
I would like to write/modify the my program ... i.e
writing a function to find out which of the directories exists .....
for example : on my computer c:\\sam and in another mechine c:\\xyz ...
only one dir should on my computer or another computer.

1. check for the each of the directories
2.if they do fine , and if they dont create and retest for them.

please let me know how to do this ..
thanks in adv

regards
sam

3
Contributors
5
Replies
6
Views
8 Years
Discussion Span
Last Post by jlm699
0

Hi , Thanks for the reply.
I am new to Python , could you pls have a sample program..
I will be very thankful to you.

Regards
Sam

0

Surely you have not tried to write your own, in the 5 minutes from my last post. Write some code, try it, if it doesn't work, post it and then we can help you more.

0

thanks for your suggestion. I am not a python programmer , I am just very new as i said in the post.

0

Here's an example:

import os

my_path = 'C:\\sam'

if os.path.isdir( my_path ):
    print 'C:\\sam is a valid path'
else:
    os.makedirs( my_path )
    if not os.path.isdir( my_path ):
        print 'Path creation failed'
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.