Paul Lemelle wrote:
I Am trying to output the os.path.walk to a file, but the writelines method
complains....
Below is the code, any helpful suggestions would be appreciated.
def visit(arg, dirnames, names):
print dirnames
dirinput = raw_input("Enter directory to read: ")
listdir = os.path.walk (dirinput, visit, None)
f = open("walktxt", "w")
f.writelines(listdir)
f.close()
os.path.walk doesn't return a list of names. I think what you want is something
like:
import os
def visit(f, dirname, names):
f.write(dirname+'\n')
f=open('c:\\walktxt', 'w')
dirinput = raw_input("Enter directory to read: ")
os.path.walk(dirinput, visit, f)
f.close()
--
http://mail.python.org/mailman/listinfo/python-list