[Tutor] Re: problems with re module

Thomi Richards thomi at imail.net.nz
Sat Nov 15 22:04:20 EST 2003


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

> You are using CurrentLine in two different places, and
> in two different ways.  Here at the beginning, it is
> a string...
>
> and now here, you change it in to a list.
>
> Try changing the name of one of these, or rethinking your algorithm.
>

While what you say it true, it works (It's not very beautiful, but it works).

I've changed it, so the loop now reads:

- --------------------------------
CurrentLine = ""
	for line in f:
		if line.isspace() or line == '':
			pass
		elif line[0] == '+':
			if initial:
				writeln("<tgroup cols='%d'>\n<tbody>\n" % (len(string.split(line,'+')
[1:-1]) ))
				initial=False
			else:
				#can we assume that formatting ends with a newline? probably - for the 
time being.
				if CurrentLine:
					writeln('<row>')
					#process the line here:
					Line = string.split(CurrentLine,'|')[1:-1]
					for col in Line:
						print "type of col is: %s \tCol is: %s" % (type(col),string.strip(col))
						writeln('<entry>%s</entry>' % procol(string.strip(col)) )
					writeln('</row>\n')


			CurrentLine = ""
		else:
			CurrentLine = CurrentLine + line
- ------------------------------------------

I'm sorry, but I still cannot see the error here.. As far as I can see, this 
*should* work..

what does the error message mean anyway? what is a "hashable" object? THat 
might enable me to debug my own programs better ;)


Thanks,

- -- 
Thomi Richards,
http://once.sourceforge.net/


-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.3 (GNU/Linux)

iD8DBQE/tuk02tSuYV7JfuERAn+2AJ4myM3mwZIxxy2cAiuqEBgB5l31lgCeK9LG
gE9Cl6HT8tw8XWYJP2AtggE=
=Jbh4
-----END PGP SIGNATURE-----




More information about the Tutor mailing list