2014年1月26日星期日

Week 3: object-oriented programming

"Object-oriented programming is a programming paradigm that represents concepts as "objects" that have data fields and associated procedures known as methods." The Python we're using now is only one of object_oriented programming languages. It's easier for me to consider everything is consisted by data fields and we can manipulate them by some certain ways.

In week 3, I have learned something new about inheritance, exception and some other methods. For inheritance, there are 2 built-in functions I have to remember. The first one is isinstance() which is used to check an instance's type, and the other one is issubclass() which is used to check class inheritance. For the part of Inheritance & Composition, I have fully understand how to write the code in both ways; however, I'm still confusing when should I use Inheritance or Composition. 
For Exception, I realized that it's important to write raise and exception or the program will stop running if error occurs. And the Try statement has 3 separate clause: try,except and finally (the last two parts can be omitted)..

没有评论:

发表评论