Class 重要觀念完整複習

  • class variables

  • 就是在 class 新增一個變數,associated with class created

  • 所有用這個 class 創造出來的 object 都可以用這個 class variables

  • 課程說明

How to use list or arrays in Python

Array vs List

Predefined Class Variables

  • 預先存好的一些變數

  • 像 __doc__

  • The function’s documentation string, orNone if unavailable

  • 可以用 Triple-quotation marks,在定義 class 的 function 內

__name__

  • The function's name

  • __module__

  • The name of the function was defined in or none

Triple-quotation marks

  • Defining a documentation in multiple lines

  • 用這個就不需要用換行符號

  • # 是 python 的評論符號

  • 案例

Inheritance

Inheritance Method

  • 你同樣可以def 一個 method,Child一樣可以繼承

  • Method Overriding - 但是如果你在Child class 內加了和 Parent 一樣的 method,他就跑 Child 內的 method

  • 實際說明


results matching ""

    No results matching ""