rabad a écrit :
Hi,
I've created a custom filter based on HTMLParser, with the following
source:
(snip)
But when I use it, it gives me the following error message:
ERROR Processor exception: AttributeError: 'list' object has no
attribute 'iteritems'
(snip)
File "d:\esp\lib\python2.3\processors\DocDumpF.py", line 178, in
__html_attrs
_attrs = ' %s' % (' '.join([('%s="%s"' % (k,v)) for k,v in
attrs.iteritems()
]))
Anybody knows why it says attrs is not a list element?
Actually, what the traceback says is that
1/ attrs is a list object
2/ list objects have no attribute named iteritems
If you assumed it was a dict, then it's probably time to re-read
HTMLParser's doc. Else if you assumed list had an iteritems method, then
it's probably time to re-read the Python's tutorial !-)
IIRC, HTMLParser represents attributes as a list of (attrname, value)
pairs. If so (please check it out), your method should be rewritten as
return ' %s' % (' '.join(('%s="%s"') % attr for attr in attrs)
As a side note: __double_leading_undescores is probably a bit extrem.
The convention for implementation attributes is _single_leading_underscore.
--
http://mail.python.org/mailman/listinfo/python-list