Monday, 2 December 2013

Week 1: Python as an Object Oriented Language

This post relates to class held from Sept 9-Sept 13.
In the first week of class the concept of object oriented programming was discussed. Basic and easy examples to Python classes were presented.
I learned an interesting way of editing a class in-line.
class ARandomClass():
def aRandomFunction(self):
return self.i 
ARandomClass.i = 3
print(ARandomClass.aRandomFunction(ARandomClass))
as opposed to
class ARandomClass():
def __init__(self):
self.i = 3
def aRandomFunction():
return self.i
print(ARandomClass.aRandomFunction(ARandomClass))
The latter definition of the class ARandomClass is much cleaner and easier to work with, however, I have a mild background of working with python among other languages, and have never seen this way of editing a class. The week left me impressed with the level understanding and knowledge coming form the professors. I was very eager to dive into the work and assignments which would come up.

No comments:

Post a Comment