Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

help using os.mkdir

Status
Not open for further replies.

Lozbinator

Programmer
Jan 13, 2003
50
AU
Hi All,

I'm trying to create a directory in my python script, the following is a snippet of some of my code:

[tt]import shutil
import os
import copy
import os.path
import os.mkdir

.....

for folder in wf:
mkdir("C:/CorVuReports/" + folder)

.....
[/tt]

Testing prior to adding "mkdir" was fine. However when I run this now, I get the error "ImportError: No module named mkdir".

I'm trying to create a directory for every item in my list "wf".

Can anybody tell me what I am doing wrong?

Thanks in advance!
 
Ok, problem is that mkdir is a method, not a module. Try:
Code:
from os import mkdir

Import has three structures, only when using the from statement can you import a specific method or variable from a module.

The grammer for this is located here:

[sub]01000111 01101111 01110100 00100000 01000011 01101111 01100110 01100110 01100101 01100101 00111111[/sub]
minilogo.gif alt=tiernok.com
The never-completed website
 
Could do this also....


import os

.....

for folder in wf:
os.mkdir("C:/CorVuReports/" + folder)

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top