problem with iteration

Panagiotis Atmatzidis p.atmatzidis at
Sat Nov 3 21:58:04 CET 2007


I managed to write some code in order to do what I wanted: Inject code
in the right place, in some html files. I developed the program using
small functions, one at the time in order to see how they work. When I
tried to put these pieces of code together I got this error:
TypeError: iteration over non-sequence

Here is the code snippet that has the issue

def injectCode(path, statcode):
	for root, dir, files in os.walk(path, topdown=True):
		for name in files:
			html_files ="html", name, flags=0)
			if html_files == None:
				print "No html files found in your path."
				for oldfile in html_files: <-- HERE IS THE ERROR
                                  [rest of code here]


I'm learning through practice and this is my first program. The error
may seem easy for you. However except from the explanation I'd like to
know how can I handle situations like the one above. I tought that
itering was valid there :-(



More information about the Python-list mailing list