Why does a Python Iterator need an iter method that simply returns self?

后端 未结 4 833
面向向阳花
面向向阳花 2021-01-06 05:35

I understand that the standard says that it does but I am trying to find the underlying reason for this.

If it simply always returns self what is the ne

4条回答
  •  礼貌的吻别
    2021-01-06 06:16

    __iter__() is intended to return an iterator over the object. What is an iterator over an object that is already an iterator? self, of course.

提交回复
热议问题