Iteration, Iterable, Iterator

  1. Iteration: A concept,一個循環
  2. Iterable:
  1. iter () method > return iterator
    2)class
    _: 包含getitem method
  1. Iterator: 任何generator都是iterator;滿足兩個條件:
  1. _ _ iter _ _() 需要 return self 2) _ _ next _ _() method implemented (for loop在使用)

    Untitled

  1. for … in interable: 執行iter(iterable), iterator = …., next(interator)

    Untitled

  2. for loop,要停止始可用stopIteration

Stdin, Stdout, Pipe

Untitled