Saturday 25 January 2014

Object oriented programs for Python

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.

Wednesday 22 January 2014

Hello all - fellow students and instructors alike. This is my introductory post pertaining to Danny's CSC148 computer science course, for the following winter session, at the University of Toronto. 

I took CSC108 last semester and thoroughly enjoyed the coding assignments given to us, having spent long hours going through all of them and helping others in the process. I did not have any computer science/programming background prior to my post-secondary years. Thanks to help from peers and instructors, specifically on the forums, the course went by smoothly and successfully for me. I hope I can have the same experience in CSC148 and help others along the way as they did for me in the past!

The first two weeks of class have been quite a smooth transition from CSC108. However, the PEP style guides for Python are a little different from what we have been taught in 108, e.g., formatting/documentation. I found this slightly annoying and wish we could have just could have just done this from the start, i.e., 108. Other than that tiny nuisance, I have enjoyed the course thus far.

I have heard great things about our head instructor, Danny, from past students taking this course, as well as CSC104. Having said that, I hope I can come out of this course, at the end of the term, enriched with further knowledge in Python and computer science in general. As a final remark, I would like to wish all of my fellow peers and teachers, as well as myself, a smooth and successful run through this course.

Until the next post, see you all at lecture!