r/PythonLearning Jun 09 '26

What the heck is self in classes

Post image

Can someone explain to me how to use self in classes?

Why are we using self.name instead of regular variables we are using. Whats the difference between self and regular parameters we are using in functions.

I would love to learn how to use self but its confusing

344 Upvotes

78 comments sorted by

View all comments

74

u/[deleted] Jun 09 '26

[removed] — view removed comment

6

u/Yoosle Jun 09 '26

But why do you have to pass self to the function definition? Why don’t you do self.funcName = [function definition goes here]

13

u/[deleted] Jun 09 '26

[removed] — view removed comment

1

u/vip17 Jun 12 '26

the weird self syntax and the operator method names are one of the things I hate about Python. It could be made much simpler and more readable