r/learnpython • u/GingerSkwatch • Feb 23 '21
Classes. Please explain like I’m 5.
What exactly do they do? Why are they important? When do you know to use one? I’ve been learning for a few months, and it seems like, I just can’t wrap my head around this. I feel like it’s not as complicated as I’m making it, in my own mind. Thanks.
229
Upvotes
View all comments
Show parent comment
5
u/[deleted] Feb 23 '21
Try to create a basic "About" program for various objects around you.
Give it attributes such as "what_am_i", "color", and "purpose"
For example: my_headphones = Item("AirPods", "white", "listening to music")
Then, maybe we want to have a function that tells us something about our class, so I could create and invoke:
my_headphones.About()
Say the "About" function printed the above 3 attributes - I can now access this object solely, without having to iterate through a list/file, etc.