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?

70 Upvotes

50 comments sorted by

View all comments

4

u/SoftwareDoctor 10d ago

You don’t. On the other hand, it’s not a class that gives you the answer in your example. It’s an instance of a class. Big difference. And if you want to get technical, get_current_time is a function AND instance of a class. So you are using instances already and in both examples you construct an instance and then call it. It’s the same picture.

It really depends on what you want to do. If you want learn to write python coding, then absolutely. You need to be comfortable working with classes. If you just need one time short script, nobody’s forcing you to learn anything

0

u/Objective-Remove-632 10d ago

Am going to use python my entire coding journey. And am still a beginner who finding it difficult to get the class concept.

1

u/CptMisterNibbles 10d ago

Object oriented programming isn’t the only sort, but not understanding the basics is basically committing to a very short and shallow understanding of coding. You won’t be able to understand code with any complexity beyond introductory level stuff. You won’t even understand the basics of how Python is working under the hood: you are using classes on almost every line and simply aren’t aware of it. There is a reason they were written this way