What is the purpose of the self keyword in Python classes?

Gihin Oha
Member
Joined: 2025-02-16 08:26:47
2025-02-16 09:06:14

I’m learning about object-oriented programming in Python, and I keep seeing the self keyword in class methods. I know it’s used to refer to the instance of the object, but I’m still a bit confused about its purpose. Can someone explain in simple terms why it’s necessary and what would happen if we didn’t use self?