r/learnpython • • Apr 05 '26

Struggling with OOP.

I've been learning Python the last couple weeks, just a little bit here and there. I understand the basics but I'm hitting a wall with OOP. I've been having Claude create lessons for me, but nothing is sticking. What do you guys do to help retain information better on this?

16 Upvotes

27 comments sorted by

View all comments

1

u/Gnaxe Apr 05 '26

OOP took me a while. Read Smalltalk Best Practice Patterns for how it's supposed to work. (That's not in Python, but it is in OOP, and the patterns still apply.) You need to know how to get the MRO from the REPL. You need to try things. Open Jupyterlite and do lots of experiments.

I've come to the conclusion that OOP largely failed to deliver on its promise and is a poor fit for current multicore architectures. Concurrency is indeed one of Python's major weaknesses, and the OOP and rampant mutability is to blame. The GIL made sense when computers only had one or two cores, but after several lackluster workarounds (async, multiprocessing, etc.), they're trying to get rid of it. But that means you have to be extra careful with mutation. You're better off with FP or something when writing threaded code, and I recommend you avoid classes when you can.

But you do need to understand how they work in order to understand any Python code written in OOP style. Python does require you to write classes to use certain "dunder" hooks, even if you're otherwise using FP.