21 lines
372 B
Python
Executable File
21 lines
372 B
Python
Executable File
#!/usr/bin/env python3
|
|
|
|
class MyNumbers:
|
|
def __iter__(self):
|
|
self.a = 1
|
|
return self
|
|
|
|
def __next__(self):
|
|
if self.a <= 10:
|
|
x = self.a
|
|
self.a += 1
|
|
return x
|
|
else:
|
|
raise StopIteration
|
|
|
|
|
|
if __name__ == "__main__":
|
|
myNumbers = MyNumbers()
|
|
for x in iter(myNumbers):
|
|
print(x)
|