Reputation: 117
I want to create a folder in the same directory, where have i gone wrong?
def selection():
print "Content Profiling"
print "~~~~~~~~~~~~~~~~~"
print " 'G', 'PG13', 'NC16', 'M18', 'R21' "
selectionInput = raw_input("Please select your content profile")
if selectionInput == "G":
root = os.curdir()
path = root+"/G"
os.makedirs( path, 0755 );
Output:
Traceback (most recent call last):
File "C:\Python27\guicmd.py", line 44, in <module>
selection()
File "C:\Python27\guicmd.py", line 38, in selection
root = os.curdir()
TypeError: 'str' object is not callable
Upvotes: 1
Views: 2407
Reputation:
os.curdir
is not a function but a constant string. Just is it as a value:
root = os.curdir
While you are at it, you can improve your code by using os.path.join
.
path = os.path.join(os.curdir, "G")
os.makedirs(path, 0o755)
Upvotes: 6