[Tutor] lxml.html
Steven D'Aprano
steve at pearwood.info
Wed Jun 8 17:36:44 CEST 2011
nitin chandra wrote:
> Hello Every One,
>
> doc = lxml.html.parse('/home/dev/wsgi-scripts/index.py').getroot()
> name = doc.forms[0].fields['name']
>
> html = 'name is '
> html += name
>
> ERROR
> [Wed Jun 08 20:29:51 2011] [error] [client 192.168.1.9] Traceback
> (most recent call last):
What is all this extraneous date/error/ip address nonsense in the
traceback? Where does it come from?
> TypeError:
> cannot concatenate 'str' and 'NoneType' objects
> I am extracting form field name / value from an html, but then it
> gives the above error and does
> not display the value of the variable 'name' entered in the respective form.
What is the value of the variable 'name'?
Hint: read the error message that you get when you try to concatenate a
string with the None object:
>>> "spam" + None
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: cannot concatenate 'str' and 'NoneType' objects
--
Steven
More information about the Tutor
mailing list