r/learnpython • u/No_Art7806 • 1h ago
Learning Python for LLM Calls and Agents
I'm a social scientist who has primarily used R for my research, but would like to learn Python so that I can more effectively use LLMs. I completed the Python Programming MOOC, so I'm familiar with basic syntax, classes, etc. I then used Claude to create a textbook with exercises to cover topics such as making API calls, validation, tools, connectors, RAG, automation, eval testing, etc.
The problem I'm facing is that the code in each exercise goes well beyond what I learned in the MOOC, so I'm getting overwhelmed and feel stuck in the weeds. For instance, there are many packages being used that I've never encountered (pydantic, pytest, os, sys, threading, argparse, hashlib, pipeline, __future__) and concepts I haven't encountered (e.g., dataclasses).
- How important is it for me to understand these concepts if I want to use LLMs for scraping, classification, running OCR on large datasets? How much would I be missing if I used codex or Claude Code to simply code the files?
- How would you recommend proceeding? On one hand, I don't want to spend excessive time on more Python tutorials at the expense of doing research, but on the other, I don't want to be missing fundamentals.
- Are there any packages/concepts you would emphasize learning beyond learning basic Python syntax?
- Could you provide resources that provide a more gentle overview of how to use Python for the purpose of using LLMs?
Thanks!
•
u/Greedy_Ad_7658 52m ago
For scraping, classification and OCR on datasets, you don't need most of that list. The textbook Claude generated is aimed at building production software (threading, hashlib, argparse, pytest), which is more than a research pipeline needs. I'd narrow it to this:
Worth learning properly:
Can skip for now: threading, hashlib, argparse, sys, future, packaging. Come back if a script needs them.
On using Codex or Claude Code to write the files: it's fine as long as you can read what it wrote. A good habit is to run it on 20 rows first, read the output by hand, and compare against labels you made yourself. For research, validation of the LLM's labels matters far more than elegant code, and that is a skill you already have. Ask the tool to explain any line you don't follow, and add pytest later, if at all.
For a gentler path, work on one small real task of your own (say 50 documents to classify) instead of the whole textbook, and learn each piece when that task needs it.
•
u/TheGlitchHammer 42m ago
I have the Feeling your question is all over the place. If you want to learn Python, do it for learning python. If its a single project you want to achieve, fundamentals + AI Agent might be enough, but that also means, you hand over control to the agent, making changing, fixing and debugging harder. I also think you treat packages the wrong way or give them to much thought. They are tools, interchangeable, there to achieve what you need them to do, they all bring their own syntax, but you dont need to deep dive/do explicit lessons on a certain tool, unless you heavily rely on it. Those that you named are mostly part of the Python Standard library, so tools that are bundled up with python. I would say, you need to know those tools as much as you must, for example how you can use os/Path to handle files. But you dont need to know how they achieve it. If you Encounter unknown concepts, let LLM describe it for you and than you can decide If you want or need to use it. So there is no real advice for you, you need to decide yourself where you want to Go with your knowledge, based in how much you will be using Python or any programming language in the future. If you want a packages that i would recommended somewhat understanding, at least for Data Manipulation, its Pandas. It is unbeliebly usefull for handling and manipulating structured data.
•
u/avalexva 16m ago
Adding to what others said, since you mentioned maybe applying for data science jobs later: the most transferable habit from that whole list is validating outputs (pydantic) and saving results to disk as you go. In real DS work the unglamorous core is exactly that — validate inputs, persist intermediate results, log what happened. Build your first classification script with those habits and you will be ahead of most juniors. And coming from R, give polars a look once you are comfortable — it feels closer to dplyr than pandas does.
0
u/ANDRE_2512 1h ago
Learning requires visualization and interactivity. Books are great. Courses are too. But nothing helps you learn as effectively as visualization.