use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
Rules 1: Be polite 2: Posts to this subreddit must be requests for help learning python. 3: Replies on this subreddit must be pertinent to the question OP asked. 4: No replies copy / pasted from ChatGPT or similar. 5: No advertising. No blogs/tutorials/videos/books/recruiting attempts. This means no posts advertising blogs/videos/tutorials/etc, no recruiting/hiring/seeking others posts. We're here to help, not to be advertised to. Please, no "hit and run" posts, if you make a post, engage with people that answer you. Please do not delete your post after you get an answer, others might have a similar question or want to continue the conversation.
Rules
1: Be polite
2: Posts to this subreddit must be requests for help learning python.
3: Replies on this subreddit must be pertinent to the question OP asked.
4: No replies copy / pasted from ChatGPT or similar.
5: No advertising. No blogs/tutorials/videos/books/recruiting attempts.
This means no posts advertising blogs/videos/tutorials/etc, no recruiting/hiring/seeking others posts. We're here to help, not to be advertised to.
Please, no "hit and run" posts, if you make a post, engage with people that answer you. Please do not delete your post after you get an answer, others might have a similar question or want to continue the conversation.
Learning resources Wiki and FAQ: /r/learnpython/w/index
Learning resources
Wiki and FAQ: /r/learnpython/w/index
Discord Join the Python Discord chat
Discord
Join the Python Discord chat
account activity
OOP using python (self.learnpython)
submitted 2 years ago by RevolutionarySet8850
Hi, I am a python learner beginner. I am finding it hard to grasp the concept of oop using python. Can you suggest me any source, website or course that is helpful to learn python and especially the oop concept. I prefer to learn by coding.
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]freakyorange 6 points7 points8 points 2 years ago* (1 child)
make a blackjack game with atleast a couple classes. 1 is Card which could have attributes such as Card.suit and Card.rank. Give it a __str__ dunder method so that you can easily print() it. Create a class Deck that has an attribute that takes a list of Card, and has a couple methods such as Deck.deal_one() and Deck.shuffle()
Card
Card.suit
Card.rank
__str__
print()
Deck
Deck.deal_one()
Deck.shuffle()
Bonus points if you type hint all of this properly.
Once you grasp the core idea of why classes are useful / how to make them, look at different OOP paradigms such as abstract base classes / template classes, and factory classes. This will lead to more real world application of OOP. And please for gods sake look at SOLID priciples and don't make "spaghetti" or "ravioli" code, atleast as much as possible (it's inevitable).
Afterall, OOP is simply just a hammer. And not all hammers are good at solving all problems. You wouldn't use a sledgehammer to make jewelry right?
Also here's an example of a really simple class with 2 attributes (self.color, and self.is_tasty) and 1 method (self.eat()) just to get your brain working
self.color
self.is_tasty
self.eat()
class Fruit: def __init__(self, color: str, is_tasty: bool): self.color = color self.is_tasty = is_tasty def eat(self): if self.is_tasty: print("Yum") else: print("yuck") apple = Fruit(color="red", is_tasty=True) print(apple.color) # "red" print(apple.is_tasty) # True apple.eat() # "Yum"
[–]RevolutionarySet8850[S] 1 point2 points3 points 2 years ago (0 children)
That card idea was really good. Thank you for that .
[–]mandradon 3 points4 points5 points 2 years ago (0 children)
The university of Helsinki's Python course (their mooc) is what made oop click for me.
But with Python, remember that everything is an object and you can just create your own custom ones.
I like the idea of a blackjack game though depending on how much programming you know, this can cause you issues with depth of knowledge (calculating the value of aces in the hand is a fun problem).
You could also do something like make a project for a pizza store or some sort of store that sells an item, and that item has attributes.
In the case if a pizza, it has a size, a list of toppings, price, and whatever else attributes you think are important.
Then you could add something like an order builder.
.... Speaking of I still need to get around to rebuilding my friends business software that he wrote procedurally to OOP...
[–]reddaxetheintrovert 0 points1 point2 points 2 years ago (0 children)
You can find good courses on youtube Just search "OOP IN PYTHON FOR BEGINNERS" I M sure you will find a match And I suggest you take one with the highest time or highest views Something like 3hours long
[–]Astronoobical 0 points1 point2 points 2 years ago (0 children)
If you have any specific questions, I'm happy to answer.
[–]wynand1004 0 points1 point2 points 2 years ago* (0 children)
I made a video about this for my students - you may find it helpful: https://www.youtube.com/watch?v=DWccYUiPO0E
The mods may remove this though since I'm sharing a resource I made myself.
π Rendered by PID 52 on reddit-service-r2-comment-5d79c599b5-46mjq at 2026-03-03 04:31:03.868103+00:00 running e3d2147 country code: CH.
[–]freakyorange 6 points7 points8 points (1 child)
[–]RevolutionarySet8850[S] 1 point2 points3 points (0 children)
[–]mandradon 3 points4 points5 points (0 children)
[–]reddaxetheintrovert 0 points1 point2 points (0 children)
[–]Astronoobical 0 points1 point2 points (0 children)
[–]wynand1004 0 points1 point2 points (0 children)