httplib HTTP class for python3?

Thomas Jollans tjol at tjol.eu
Sat Jun 10 06:52:51 EDT 2017


On 10/06/17 11:33, Mohammad Ghasemi wrote:
> Hi.
> I want to convert a python 2 code to python 3 code and I have a problem with that.
> I've asked my question on stackoverflow and never received an answer.
> Where can I get an answer?
> 
> https://stackoverflow.com/questions/44411439/httplib-http-class-for-python3
> 

You asked this only two days ago. "never received an answer" is a strong
statement considering.



As you obviously know, httplib as has renamed http.client.

> [...] from http.client import HTTP will not work.

According to the documentation
<https://docs.python.org/2/library/httplib.html>, the HTTP class is
ancient and "should not be used in new code". It makes sense that it
would have been removed in Python 3.0 - looks like you should just use
HTTPConnection.

More generally:

If you say something does not work, please provide a complete minimal
working example with an error message. Otherwise there is no way anybody
can know what it going wrong.

You provided example code (great!) but it's not complete: you are using
things without importing them, and it doesn't look like your code would
actually do much of anything if the relevant modules *were* imported.


-- Thomas



More information about the Python-list mailing list