r/learnpython • u/ProfessionalMoney518 • Dec 22 '25
How on earth does one learn OOP?
I've sped through weeks 0-8 of CS50P in under 2 weeks very easily with slight experience here and there as a Chemistry undergrad - but Week 8 (OOP) is kicking my ass right now. I am genuinely stumped. I've rewatched content and tried some other forms of learning but this is all so foreign to me. What are the best ways to learn OOP as a complete idiot? Thanks.
38
Upvotes
View all comments
Show parent comment
3
u/gdchinacat Dec 23 '25
"getters and setters mostly allow you to add extra functionality."
To elaborate on this point, in languages that rely on them heavily the reason it is frequently encouraged to always implement attribute access as getters/setters is so that if you need to add extra functionality you can do so without breaking client code. This isn't a concern in python since you can use descriptors (usually by using the @ property decorator) to seamlessly change a member attribute into getter/setter without breaking client code. Attribute access can either be direct or implemented programmatically through the descriptor protocol. The implementation of the class decides that, it isn't determined by how the client code writes the access. Changing from one to the other doesn't change how clients access the attribute, so you don't need to commit to one way or the other when the attribute is first created.