Class vs Function-(Python)
DavidClone (3)

Why does class exist when we have functions? I know how to create a class but I don't understand why we need to use class.

You are viewing a single comment. View All
Answered by ash15khng (304) [earned 5 cycles]
View Answer
Geocube101 (258)

Classes can be useful for creating instances and applying values to an object
Functions are reusable pieces of code used for doing stuff
Classes are also reusable, but can apply their values to a variable
I use them for when I want a set of available functions for a variable instance.
Before I knew how to make classes, I created a set of functions that did different things to lists. The object itself was never modified, but a copy was made and returned. With classes, I could drop a parameter (as I had a parameter for the array) and modify the original object.

DavidClone (3)

@Geocube101 This helped "unconfuse" me! Thanks!