problem with iteration

Panagiotis Atmatzidis p.atmatzidis at gmail.com
Sat Nov 3 16:58:04 EDT 2007


Hello,

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 = re.search("html", name, flags=0)
			if html_files == None:
				print "No html files found in your path."
			else:
				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 :-(

Regards,

atma




More information about the Python-list mailing list