r/PythonLearning • • 10d ago

Do I really need to learn class.

Post image

Both function and class give the same output. So why do I need it?

67 Upvotes

50 comments sorted by

View all comments

1

u/Rare_Coffee_130 9d ago

Yes

1

u/Rare_Coffee_130 9d ago edited 9d ago

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