摘要: In the previous section we added two Time objects, but you also might want to add an integer to a Time object. The following is an alternative version... 阅读全文
posted @ 2014-10-02 22:23 平静缓和用胸音说爱 阅读(201) 评论(0) 推荐(0) 编辑
摘要: By defining other special methods, you can specify the behavior of operators on user-defined types. For example, if you define add method for the Time... 阅读全文
posted @ 2014-10-02 20:52 平静缓和用胸音说爱 阅读(235) 评论(0) 推荐(0) 编辑
摘要: __str__ is a special method name, like __init__, that is supposed to return a string representation of an object.For example, here is a str method for... 阅读全文
posted @ 2014-10-02 20:23 平静缓和用胸音说爱 阅读(218) 评论(0) 推荐(0) 编辑
摘要: The init method is a special method that gets invoked when an object is instantiated. Its full name is __init__ (two underscore characters, followed b... 阅读全文
posted @ 2014-10-02 15:59 平静缓和用胸音说爱 阅读(201) 评论(0) 推荐(0) 编辑
摘要: Python is an object-oriented programing language, which means that it provides features that support object-oriented programming. It is easy to define... 阅读全文
posted @ 2014-10-02 15:27 平静缓和用胸音说爱 阅读(275) 评论(0) 推荐(0) 编辑
摘要: Sometimes it is useful for a function to modify the objects it gets as parameters. In that case, the changes are visible to the caller. increment, whi... 阅读全文
posted @ 2014-10-02 13:12 平静缓和用胸音说爱 阅读(295) 评论(0) 推荐(0) 编辑
摘要: In the next few sections, we’ll write two versions of a function called add_time, which calculates the sum of two Time objects. They demonstrate two k... 阅读全文
posted @ 2014-10-02 11:01 平静缓和用胸音说爱 阅读(182) 评论(0) 推荐(0) 编辑