In csc108, I constantly used classes, such as str, list, and int. However, I never quite grasped, or paid attention to, the meaning behind them and how they worked - I only cared about the final result. After the past three weeks in csc148, the course is beginning to open my eyes and broaden my mind towards the bigger picture - the whole spectrum - of what Python, and other programming languages alike, is really about. I understand that Python is an 'Object Oriented Program', based on objects being constructed by a class in the form of instances (and instance variables within the object). The class is a factory that creates objects able to interact with other classes, and methods within the classes in order to manipulate the object. For example, 'Student' would be a class, 'Bill' would be an object (or instance within a class), and 'grade' would be the instance variable for Bill. We can continue to add/create more instances from the class and then call methods from a class to do what we want with the objects. This is how a list class would work, e.g.,
Working in the shell,
>>> a = []
'a' is an object(instance) created by the class 'list'. Now we can call a method from the list to do what we want with 'a', e.g., append, which adds the chosen variable into the instance.
>>> a.append(1)
Calling the object would give us,
>>> a
[1]
However, I was, and still am, quite riled up between modules and classes. Can we not just create a module with a lot of functions, and call on that module to preform desired tasks, instead of creating classes? More importantly, what is the difference between a module and a class? This is something I hope to figure out and understand soon.