Follow

The python requests library is widely used and respected. But it contains almost 7,000 lines of code and with it's own dependencies over 24,000 lines of code. Each one of those could have bugs or security holes someday. Having a dependency like this could or expose you to things like medium.com/checkmarx-security/

Did you know the python standard library can make http requests with urllib? It is a little clunkier interface wise, but it works for everything I've thrown at it.

· · Web · 2 · 0 · 0

There's a lot in the standard library that people don't even know about including: an http server, the ability to use a sqllite database directly, turtle-style graphics, C bindings for gui applications with TCL and probably more I haven't learned about. By learning what is in it, or other languages standard libraries you can make your applications and libraries much more stable, secure and resilient. Read those docs before reaching for a third party alternative!

@Natris1979
I was lately writing script that needed to do some http requests, and I have used requests just because you use it exactly the same way in Python 2 and 3, which made it easier to make the script work on both python major versions, which was necessary

@Natris1979
But where I can, I am trying to avoid external dependencies, just to let stuff be deployed easier, and to not rely too much on separate stuff

@Szwendacz you could use `sys.version` to check the python version and use the varying syntax accordingly. If you put this in your own function or class then use that in the rest of your code you could avoid having this kind of logic polluting your entire codebase.

But, yes there are some cases where using a library like requests makes sense. My intention is to make people *think* before using a library like this when there are other solutions.

Sign in to participate in the conversation
Linux.Pizza

A instance dedicated - but not limited - to people with an interest in the GNU+Linux ecosystem and/or general tech. Sysadmins to enthusiasts, creators to movielovers - Welcome!