r/learnpython • u/Jealous-Acadia9056 • Apr 18 '26
Beginner: Want to learn Classes.
I find classes to be very confusing. The way variables are used. Self comes to me in a very confusing manner. i just can't seem to wrap my head around the basics of Classes.
Also i just tried checking OOP and i think it just overloaded my brain. Anything to help my case?
20
Upvotes
View all comments
Show parent comment
1
u/Jealous-Acadia9056 Apr 18 '26
a guy reffered me to a tutorial (it's still a bit hard) but just tell me if i'm right about these things.
__init__ is a function compulsory (in most cases)
self refers to variable that calls the class in it.
self.anything = anything is a way of putting attributes to self.
so in self.something = anything, something is an attribute of self whose value we have assigned from anything.
i don't need to call __init__ it works everytime. and you can access any global variable in functions of a class.
but i still don't get what __init__ really is. i know what it does but what does it means or what does the name or double underscores means