2015年3月1日星期日

WEEK7 Please mark my OOP post.

I don't know if you will go into my OOP post and mark it or somehting.. but anyway I have copied my entire OOP post here.

In an Object Oriented Programming language such as python, everything is referred as an object.
A list is an object;  a class is an object; a function is an object; even None is an object known with the type 'NoneType'.
In python, every value is an object and has a memory address. For example, when we type 'x = 3' into python, it does not mean that x has the value of 3, but instead, it means that x is pointing to a certain memory address, and such address contains the value of 3. So, in another word, an object is a piece of memory.
Different objects could have the same value. For example, if we type 'x = 3' and 'y = 3' into python, python will create two objects separately in memory id1 and id2, and both memory address will contain the same value known as 3.
Objects could contain both information and behavior. Given an example of a list object, it contains the information of a list the memory address that are pointing towards the values of the values in the list, and it also contains behaviors such as sorting the list or measuring the length of the list. We use a dot '.' in python to call those methods of an object.

没有评论:

发表评论