r/PythonLearning • u/Objective-Remove-632 • Oct 09 '26
Do I really need to learn class.
Both function and class give the same output. So why do I need it?
70
Upvotes
r/PythonLearning • u/Objective-Remove-632 • Oct 09 '26
Both function and class give the same output. So why do I need it?
View all comments
Show parent comment
1
u/Rare_Coffee_130 Oct 10 '26 edited Oct 10 '26
Classes have a lot of benefits, it also help you to have a better control of your elements, good structure and easy to have multiple variables with the same behavior without copy and paste over and over again what's inside of them.
You create something like a User class and boom, you just do:
User1 = User()
User2 = User()
And that's it, you have 2 instances of User. If you need to modifying something then you just go to your User class and do the change there, it will be applied to any object / instance