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
12
u/[deleted] Feb 24 '21
It's not something that you have to understand to start using classes, but basically the method needs some way of obtaining all of the data attributes (and potentially the other class methods) you have associated with the instance. So when you use dot notation to call
my_object.method_name(), themy_objectinstance is automatically passed as the first argument tomethod_name(). That's howmethod_name()obtains access to those data attributes.