Unable to write output from os.path.walk to a file.

Paul Lemelle pdl5000 at yahoo.com
Wed Jun 4 14:54:37 EDT 2008


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()

 


      



More information about the Python-list mailing list