Comment by Kwpolska

16 hours ago

The standard library is full of dead batteries. If the stdlib is so good, why does everyone install requests instead of using the stdlib http client? And why requests or something like it hasn't been adopted into stdlib after so many years of stability?

Parts of requests has been adopted into stdlib: https://docs.python.org/3/library/urllib.request.html

People mostly defer to requests because they do not track language development closely and because we are creatures of habit.

I try to avoid non-stdlib packages when stdlib will do a good job, but I received negative feedback from people who aren't aware of the updates and couldn't foresee supply-chain attacks.

  • The current standard library urllib is a refactoring of previous attempts from the 2.x standard library, and urllib.request is just a sub-package. It does not represent adoption of requests; requests builds on urllib3, which was created to fill in gaps in what the standard library provided, and named like that because the 2.x standard library had both a `urllib` and a `urllib2` as they struggled to figure it out.

    • For a long time, urllib had everything deprecated except for the parsing code which remained relevant as the upstream RFCs have not changed IIRC.

      Urllib2 is now also gone and mostly replaced with urllib.request.

      It should cover 99% of the use-cases one would use requests for — I am not sure how and why it matters that it is a subpackage and not a top-level package?

      This is just a natural evolution of a widely used language where you have to be careful with backwards compatibility.

You are picking one of the weak points of the standard library and an unusually popular replacement (and AFAIK it is built on the standard library). I cannot think of many others that are widely used. Maybe lxml ?

A Python codebase might well use requests, but it will almost always also heavily use the standard library.

Because the typical Python programmer does not appreciate the advantages of a slightly rusty stdlib compared to reaching for the bedlam that is PyPI.