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?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
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.