r/learnpython • • 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

71 comments sorted by

View all comments

Show parent comment

19

u/ChurchHatesTucker .141592 Feb 24 '21

struggling with why self as an argument then gets used as self.type, self.balance, etc

You need self.balance so you can have Unicycle.balance, and since self has to come from somewhere it gets passed as an argument.

At least, that's how I remember to include it.

Fun fact: it doesn't have to be called self. The first argument to init will always function as self. Call it yomamma on your next assignment.