以返回构建range函数基本功能为例
ex:
class a:
def __init__(self,x,y):
self.x=x
self.y=y
def __next__(self):
if self.x>=self.y:
raise StopIteration
m=self.x
self.x+=1
return m
def __iter__(self):
return self
def __init__(self,x,y):
self.x=x
self.y=y
def __next__(self):
if self.x>=self.y:
raise StopIteration
m=self.x
self.x+=1
return m
def __iter__(self):
return self