Skip to content

Commit ec27b87

Browse files
committed
compatible with python3
1 parent 916e5ff commit ec27b87

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

dir_test.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,20 @@
88
# Description : Tests to see if the directory testdir exists, if not it will create the directory for you
99
from __future__ import print_function
1010
import os #Import the OS Module
11-
CheckDir = raw_input("Enter the name of the directory to check : ")
12-
print
11+
import sys
12+
13+
if sys.version_info.major >= 3:
14+
input_func = input
15+
else:
16+
input_func = raw_input
17+
18+
CheckDir = input_func("Enter the name of the directory to check : ")
19+
print()
20+
1321
if os.path.exists(CheckDir):#Checks if the dir exists
1422
print("The directory exists")
1523
else:
1624
print("No directory found for "+CheckDir) #Output if no directory
17-
print
25+
print()
1826
os.makedirs(CheckDir)#Creates a new dir for the given name
1927
print("Directory created for "+CheckDir)

0 commit comments

Comments
 (0)