File tree Expand file tree Collapse file tree 1 file changed +10
-5
lines changed
Expand file tree Collapse file tree 1 file changed +10
-5
lines changed Original file line number Diff line number Diff line change 99# Description : Checks to see if a directory exists in the users home directory, if not then create it
1010
1111import os # Import the OS module
12+ MESSAGE = 'The directory already exists.'
13+ TESTDIR = 'testdir'
1214try :
13- home = os .path .expanduser ("~" ) # Set the variable home by expanding the users set home directory
14- print (home ) # Print the location
15-
16- if not os .path .exists (os .path .join (home , 'testdir' )): # os.path.jon() for making a full path safely
17- os .makedirs (os .path .join (home , 'testdir' )) # If not create the directory, inside their home directory
15+ home = os .path .expanduser ("~" ) # Set the variable home by expanding the user's set home directory
16+ print (home ) # Print the location
17+
18+ if not os .path .exists (os .path .join (home , TESTDIR )): # os.path.join() for making a full path safely
19+ os .makedirs (os .path .join (home , TESTDIR )) # If not create the directory, inside their home directory
20+ else :
21+ print (MESSAGE )
1822except Exception as e :
1923 print (e )
24+
You can’t perform that action at this time.
0 commit comments