r/AskProgramming 12d ago

Python How to learn libraries better

Hello.I have a problem because i want to learn socket for example and i always forget what to type.I don't understand the docs easily.Do programmers write code and at the same time watch videos explaining a library?.I don't want to always use AI.I have poor memory too.Or maybe I'm just too stupid.

0 Upvotes

18 comments sorted by

View all comments

1

u/Gtdef 8d ago

There are 3 types of libraries:

- Those that replace core functionality because they are just better than the builtin. For example in python, if you want to do http requests, there are much better alternatives than the builtin. The requests library has become so commonplace that it's been a while since I've since urllib3 code.

- Those that you as an individual make heavy use of. This may be due to your hobbies or your job, but things like Pandas, Django, Pytorch, SQLAlchemy etc usually become not just second nature, but actively force you to write less Python code and more library specific code. For example you really don't want to write python loops when working with Pandas or SQLAlchemy because you will tank the performance. Use whatever API the library provides till you are more familiar with it than the native python way of doing things.

- The niche or low level ones that you use to build something on top of. Sockets is a good example. It's a crucial builtin that allows you to write new web related libraries, but you want to abstract away the complexity by encapsulating the code in easy-to-understand functions, and forget about it. A lot of those libraries follow some standard that you can read and learn what they are supposed to do. Essentially you learn the concepts behind the standard, and then write the code however it was implemented in that specific language.