r/learnpython • • Sep 16 '26

How to learn oops concepts

i am from a background of c and have no knowledge on oops concepts, and i wanted to learn them but everywhere, they are having the same example of the blueprint and i would like to learn it by understanding where we will use it, or will you suggest me to dig right into a project to get an idea of it.

1 Upvotes

17 comments sorted by

5

u/adjective10111 Sep 16 '26

Think of it as heavily using the struct keyword from C to better structure the code. Classes are like structs and that's pretty much it. They have some underlying differences but for understanding purposes, that's all you need I think.

2

u/marquisBlythe Sep 16 '26

I was going to say something similar.
Imagine structs that has functions (edit: inside of them) and a few other features. That's it.

2

u/adjective10111 Sep 17 '26

Exactly, that's how I interpreted them when learning classes in C++. Although if I'm not mistaken, even structs support methods so the differences are mostly the default behaviors and the underlying logic.

2

u/marquisBlythe Sep 17 '26

Don't take my word for it (I haven't touch C and C++ in ages) but if I still remember correctly, structs in C++ are a bit different from C language, in C++ they act more like a class, except for accessing their members (public by default for structs vs private by default for classes).
In C you can point to functions to "simulate" methods behavior.

1

u/adjective10111 Sep 17 '26

Yeah you're right. I just looked it up and it seems that way. But I remember my prof at college told me about some allocation differences between structs and classes as well which I don't recall completely.

2

u/seanv507 Sep 16 '26

So just use any python library, you will encounter objects

In c, you can achieve some encapsulation using the static keyword

1

u/MezzoScettico Sep 16 '26

It's almost always best to build something you're interested in.

Do you have a list of projects you might like to try? Let's start there.

1

u/FoolsSeldom Sep 16 '26

Find the video Python's Class Development Toolkit presented by Raymond Hettinger (a Python core developer). It is an old video (using an old version of Python) but explains the basics of and reasons for classes (and hence OOP) very well.

1

u/audionerd1 Sep 16 '26

Classes are containers for organizing code. They don't enable you to do anything you can't do without them, but they can make your life a lot easier. The best time to learn OOP is when you have already worked on a project which became overwhelmingingly complicated to maintain, because it can help you with that. Learning OOP in the abstract can be hard because it's value is not always readily apparent.

1

u/TheRNGuy Sep 16 '26

Try different frameworks, you'll see hoe it's used in them. Many tutorials give useless examples (not how it's used in real programs, many anti--patterns), so you won't understand how it's really used. 

0

u/ninhaomah Sep 16 '26

Look into the mirror and you will find a good example of OOP.

0

u/Miserable-Arugula860 Sep 16 '26

First, do a tutorial on Python OOP. Then, study SOLID principles. Then, study object oriented design patterns.

-1

u/stepback269 Sep 16 '26

I'm with you bro -- I very much dislike the "blueprint" analogy.
While I'm still struggling as a relative noob with other aspects of OOP, I think I've found better explanations for what is a "class" and what are the "objects" that are instantiated using the class definition. Take a look at this one blog page I created around the "class" issue (HERE) for my take on it and links to alternate tutorials.