Iteration may be (Interable), iterator (Iterator), generator (Generator) of Notes

Now we see here today, make a note of it. The stuff I've spent a lot of time.

Iterable as long as there __iter__ properties can be called iteration (Interable).

Iterator just have __iter__ and __next__ property is the iterator (Iterator).

Python iterator which may be generated (the Iterator) by the method iter, iter (iteration can (Interable))

Generator (Generator), it can be simple generators (i, for i in range (10)), with the writing style list generator general, the [] with (),

There can be used a method of generating a custom yield.

Generator is definitely an iterator, more is iterables, the generator function is the most

The method is relatively exclusive iterator has three generator object:

  • send
  • throw
  • close

Simply put, the iterator only values ​​from an object inside, the generator can interact, you can also send the value of the objects inside.

yield, send, throw, close. I do not write here, and lengthy.

You can refer to: https: //blog.csdn.net/jpch89/article/details/87036970

Most will yield and send for general use, Ctrip time to use.


There can be used a method of generating a custom yield.
[Picking yǒu keyǐ Tongguo zì Dingyi fangfǎ Shengcheng Yong yield.]
There can be used a method of generating a custom yield.

Guess you like

Origin www.cnblogs.com/sidianok/p/11795975.html