noobie mkdir problem/question

ProvoWallis gshepherd281281 at yahoo.com
Sat Mar 25 22:41:44 CET 2006


Hi,

I'm trying to write a script that will create a new directory and then
write the results to this newly created directory but it doesn't seem
to work for me and I don't know why. I'm hoping someone can see my
mistake or at least point me in the right direction.

I start like this capturing the root directory and making my new
"xrefs" directory (I can see the new folder in windows explorer):

root = raw_input("Enter the path where the program should run: ")

xrefs = os.path.join(root,'xrefs')

if (os.path.isdir(xrefs) == 0):
     os.mkdir(xrefs)
else:
     sys.exit('LOG folder already exists. Exiting program.')

...I do everything else...

And then I'm trying to write the results out to xrefs. But instead of
writing to xrefs they're written to the original directory, i.e., root.
and I'm not sure why.

outputFname = given + '.log'
outputFile = open(os.path.join(xrefs,outputFname), 'w')
outputFile.write(data)
outputFile.close()

Anyone?

Thanks,

Greg




More information about the Python-list mailing list