Response codes and \r\n

Richard Brodie R.Brodie at rl.ac.uk
Thu Mar 5 06:02:55 EST 2009


"Catherine Heathcote" <catherine.heathcote at gmail.com> wrote in message 
news:N3Nrl.2951$Lc7.2213 at text.news.virginmedia.com...
=
> I am reading an XML file (code at the end if it helps) and all goes well except I am 
> getting the http response code printed.

I suggest you comment out line 22. The status shouldn't be in the data.

> Also everything I get has "\r\n" in it, which atm I am getting rid of with strip(), is 
> that the best way?

I would use and XML parser such as Elementtree, and let it handle it.
Resist the temptation to think "it's a simple format, I'll parse it myself".
Otherwise strip() or rstrip('\r\n') is fine, depending how much whitespace
matters.

> conn.close

Note that statement does nothing, it's not the same as conn.close() 





More information about the Python-list mailing list