Obscure Exception message

Daley, MarkX markx.daley at intel.com
Thu Jun 8 17:14:09 EDT 2000


Hi, all!

I'm still trying to catch up on my Python reading (>50 messages!), but I
have a problem with a while loop I'm using.  Hope someone can help.

alphadict = {}
for i in range(len(result)):
	c = 1
	serialnum = result[i][6]
	try:
		while serialnum in alphadict[c]:
			c = c + 1
		alphadict[c] = alphadict[c] + [serialnum]
	except KeyError:
		alphadict[c] = serialnum
print len(alphadict)

The print len(alphadict) is there to let me know if it has done the job or
not.  Basically, I anticipate the length being >1.  Here is the exception
message.

Traceback (innermost last):
  File "C:\Program Files\Python\Pythonwin\pywin\framework\scriptutils.py",
line 237, in RunScript
    exec codeObject in __main__.__dict__
  File "C:\Program Files\Python\cit.py", line 63, in ?
    while `serialnum` in alphadict[c]:
TypeError: string member test needs char left operand


I have no idea what this is telling me, although the 'char' comment makes me
wish I had a flamethrower!

TIA

- Mark





More information about the Python-list mailing list