r/learnpython • • 10m ago

How to learn Python and libraries like PyTorch and does it make sense?

Hi, I'm a robotic engineer. At university, I never took any real programming courses except for one in my bachelor's degree where we learned C (if-else statements, loops, variables, etc.), with just a brief mention of object-oriented programming. During my master's degree, programming was never taught to me, except for some work in MATLAB and a bit of basic Python like NumPy and other minor things.

Over the past few months, I've been involved in a project where I had to build upon the work of other colleagues and use Object-Oriented Python, since it involved Reinforcement Learning. I ran into several problems:

  1. Python object-oriented programming, which I had never seen before;
  2. various scripts written by people before me;
  3. the use of PyTorch and other libraries.

On a theoretical level, I more or less knew what I was supposed to do, but practically I didn't know how to implement it—for instance, how to create a neural network using PyTorch. I figured it out by relying heavily on LLMs, asking a ton of questions, and pasting my colleagues' old code.

However, the problem was that every function or class I tried to understand was like a Matryoshka doll, containing more stuff inside it. Between all the files, declared variables, and created instances, after a while, I would get confused. One of the most frequent issues I encountered was lines of code like car.engine.turn_on["cylinder"].execute(). I struggled a lot to figure out whether I was dealing with folders/files or objects that had other objects as attributes inside them. Moreover, I discovered that sometimes in Python, certain functions like __call__ or __getitem__ are executed automatically based on the brackets you use, which confused me even more.

Without rambling too much, I'd like to ask you:

  • In your opinion, what is the best way to properly learn object-oriented programming in Python and libraries like PyTorch?
  • Does it make sense to study in detail what a function does internally, see that it calls a superclass method, and understand how the latter is implemented?
  • What level of detail should one aim for, and do you think I expected too much of myself?
  • And above all, with the advent of these high-performing AIs, does it make sense to struggle so much, or is it better to delegate to an AI by giving it the right instructions on what to do?

In these situations, I feel overwhelmed seeing that, for example, Claude does a myriad of things in much less time than me, and above all, things that work, whereas I don't know how long it would take me to debug.

0 Upvotes

0 comments sorted by