Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Question about classes
#1
Hi,

I am learning Python as my first programming language and I love it - I follow a course on Coursera and two others on Edx, plus tons of YT channels and such. Right now I am learning about classes and although I understand their functionality and how they work, I have some trouble understanding the necessity or the benefits of using them. Let me explain:
Basically, as far as I understand, I can do everything without using classes- and please correct me if I'm wrong. They seem to me just like over-complicated functions, or a kind of a function on top of some other functions- please correct me if I'm wrong. In one of the videos I saw, the instructor was saying that classes are meant to organize functions based on their common functionality, like having a class called "math ops" for instance where one can define all the math ops one desires . Which I get, but why is that different from using a simple .py module with all the various functions and import and reuse or extend them from there? What is best practice? When does one use classes vs. functions? If classes are "better"- which already sounds a bit dumb if I put it like this- or offer a better functionality, why don't we use them all the time? I did a huge amount of exercises, and there just a few of them that involve classes. Usually the solutions I see just use plain functions instead...I find it very confusing.
I'm sorry if this seems naive, I would greatly appreciate your advice on this!
Reply


Messages In This Thread
Question about classes - by radoo - Jun-29-2020, 10:41 AM
RE: Question about classes - by GOTO10 - Jun-29-2020, 02:05 PM
RE: Question about classes - by radoo - Jul-01-2020, 01:23 PM

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020