We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent ade29d6 commit d752949Copy full SHA for d752949
patterns/behavioral/iterator_alt.py
@@ -4,6 +4,7 @@
4
*TL;DR
5
Traverses a container and accesses the container's elements.
6
"""
7
+from __future__ importannotations
8
9
10
classNumberWords:
@@ -17,14 +18,14 @@ class NumberWords:
17
18
"five",
19
)
20
-def__init__(self, start, stop):
21
+def__init__(self, start: int, stop: int) ->None:
22
self.start=start
23
self.stop=stop
24
-def__iter__(self): # this makes the class an Iterable
25
+def__iter__(self)->NumberWords: # this makes the class an Iterable
26
returnself
27
-def__next__(self): # this makes the class an Iterator
28
+def__next__(self)->str: # this makes the class an Iterator
29
ifself.start>self.stoporself.start>len(self._WORD_MAP):
30
raiseStopIteration
31
current=self.start
0 commit comments