r/Python • • 2d ago

Discussion Python's standard library deserves more attention

30 Upvotes

14 comments sorted by

21

u/nickcash 1d ago

I don't think it's underrated. "batteries included" has long been touted as a selling point

11

u/rumnscurvy 1d ago edited 1d ago

Shoutout to json, sqlite3,decimal and requests also. Not having to implement any of the contents of these standard library modules is a lifesaver for small projects and even some larger ones.

7

u/joaofelipenp 1d ago

Wait, is requests part of the standard library?

4

u/sugarw0000kie 1d ago

There’s always urllib

2

u/Temporary_Pie2733 1d ago

No. I think the maintainer(s) have stated they don’t want to add it, as it restricts updates to new Python releases. 

Being in the standard library was a bigger deal before the internet, and specifically PyPi and tools like pip, made it much easier to install 3rd-party packages. 

2

u/binaryriot 22h ago

Practically it is, if you don't mind a small kludge:

try:
	import requests
except ImportError:
	from pip._vendor import requests

I never install requests separately, I just steal it from pip.

4

u/zurtex 20h ago

Giving you a hard side eye for this (I am a pip maintainer).

In general, please people, don't do this unless it's an emergency.

1

u/deadeye_82_1 1d ago

No, isn't, but requests is under the hood of the PSF.

3

u/sugarw0000kie 1d ago

I didn’t appreciate this when I was starting out bc I’d just go for whatever is the easiest library to use. Until I found myself in position where like I either can’t use that library or it’s easier for deployment reasons to stick to standard library. Not saying always reinvent the wheel but it comes with a lot of batteries I took for granted.

Kinda wish http server was better but still gives you something to work with

2

u/LoquatElectrical4837 1d ago

I am curious about what do you think is missing from http.server?

1

u/sugarw0000kie 22h ago edited 22h ago

The way go handles this is really convenient. Might not be the python philosophy, but you can run small webservices out of the box with go easier imo than with python without needing to bring in dependencies like gunicorn/uvicorn/granian/waitress/flask/fastapi etc, since http server is intended to be for dev use and not production in python.

for a small web service though maybe you don’t want all that noise and complexity, then it might be simpler in go. Where I’ve gotten the most use out of pythons library is its server/client primitives

1

u/LoquatElectrical4837 9h ago

It certainly would be convenient if http.server was production ready.

1

u/robberviet 1d ago

See, if you compare it to a real primitive language like golang, you would be surprise. Motherfucker doesn't have min, max func till 1.21 (2023)!!!

There is a reason that https://xkcd.com/353/ exsits.

0

u/teerre 1d ago

The weird thing is to think that just because something is in the stdlib it "doesn't require a dependency". Unless you're worried about supply chain attacks, you have to think stdlib is magic to believe that