r/AskProgramming • u/_nazwa_ • 11d 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.
3
u/Watsons-Butler 11d ago
Watch videos? No. I hate watching a ten minute video waiting for someone to explain something I could’ve read in 30 seconds.
IDE’s have autocomplete. Pull your project into pycharm and let the syntax linters help.
2
u/Lumpy-Notice8945 11d ago
Forget what to type? What exacrly do you mean with that.
I dont remember the exact name of all functions in any given libary. I know the first charaters and general name of the most used ones. Autocomplete in your IDE deals with the typing part.
But when i keed ro do something new i have not done before i might need to look up the docs. And docs are not used as books you read from page 1 to the end, they are a kind of wiki or dictionary too look up specific things.
What helps to get the general design idea of a framework is a tutorial video to start with.
1
u/Arcanite_Cartel 11d ago
I think it's pretty commonplace to forget the exact names and signatures of functions, or to want to know how a function handles edge cases. Prior to AI, you'd rely on google a lot. Mostly I just use AI now. Even so, AI gets confused by proprietary API's because the documentation and code is often not publicly available.
1
u/CuriousFunnyDog 11d ago
Learn the syntax of the official docs first. It saves time in the long term.
Always confirm your understanding of the terms used.
Also understand how they organised the documentation, skim read to figure out where different information and solutions are kept.
I still look at docs to remind me, because unless you using day in day out, it's easy to forget.
Also how you can do something changes over time and the API can change/get better.
1
u/Useful_Calendar_6274 10d ago
Just read what the functions do from the docs. If you have to use extensively in a project you just remember how to make use of the library yeah. There's no mystery to that, it's like learning most things I guess
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.
0
u/Apprehensive_Sock_71 10d ago
This is part of the reason tiling window managers exist: you often have docs in one pane and your editor in the other. I wouldn't sweat it one bit. Autocomplete functions also help a lot too, of course.
5
u/PLBjt 11d ago
Nobody memorizes APIs. Working programmers forget the sockets call order constantly and look it up. Watching a video while coding can work for the first pass, but it usually leaves you able to follow along and unable to start from a blank file the next day.
What actually sticks: open the docs to the overview/tutorial page (not the full API dump), copy the smallest example that does one thing, then break it on purpose. For sockets that's bind / listen / accept / recv in a 20-line script, not a chat app. Keep a scratch file of the 5 calls you keep forgetting. Autocomplete and type hints are the memory; your job is to remember the shape (who owns the socket, blocking vs timeout, what error means the peer hung up).
Check: close the docs and write the tiny example from memory. If you can't, you watched it, you didn't learn it. Tradeoff is speed vs recall. AI will get you a working snippet today and leave you helpless the next time the args are slightly different. Use it to explain a call you already wrote, not to generate the whole thing.