Thursday 23 January 2014

Week 3 of Csc148

This week I learned about creating subclasses and raising exceptions. the professor created an intstack subclass from the superclass Stack.The intstack subclass inherits all of the superclass's methods and operation unless a method of the same name is created within the subclass in which case python uses the subclass's method when called on an object of the subclass. I had a little trouble with catching and raising exceptions though. I understand how using an if statement we can catch an input we might not want in our methods hence stopping the operation and raising an exception. But the final example(http://www.cdf.toronto.edu/~heap/148/W14/Lectures/danny/W3/exceptions.py) on Monday left me a little confused over the difference between raising and catching an exception. However going over it again I realise this was a problem of classes and subclasses rather then exceptions.

I had a little trouble with Lab last week but the Lab this week went really well and my partner and I managed to finish our work well ahead of time. Lab exercises were easy this week in the sense that the Class Queue that we had to create was more or less a direct copy of the Class Stack. The final question on the efficiency of the Class  left me a little puzzled. I understood that the reason why Class Queue took longer was because it had to keep track of objects in both ends of list in Queue. Does this mean python has cycle through the whole list from back to front in order to perform dequeue since we are removing an object from the other end from where it was added?