I'm new to python. I've studied C and I noticed that that the C structure (struct) seemed to have the same task as "class" in python. So what is, conceptually, the difference?
Structs encapsulate data.
Classes encapsulate behavior and data.
Aside from numerous technical differences between how they're implemented, they serve roughly the same purpose: the organization of data.
The big difference is that in Python (and other object oriented languages such as C++, Java, or C#), a class can also have functions associated with it that operate only on the instance of the class, whereas in C, a function that wishes to operate on a struct must accept the structure as a parameter in some way, usually by pointer.
I won't delve into the technical differences between the two, as they are fairly significant, but I suggest you look into the concept of Object Oriented Programming.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With