1.1 --- a/lib/__builtins__/span.py Sat Dec 10 18:52:54 2016 +0100
1.2 +++ b/lib/__builtins__/span.py Sat Dec 10 18:54:07 2016 +0100
1.3 @@ -71,8 +71,6 @@
1.4 else:
1.5 raise ValueError(self.step)
1.6
1.7 - self.current = self.start
1.8 -
1.9 def __len__(self):
1.10
1.11 "Return the length of the range."
1.12 @@ -83,14 +81,27 @@
1.13
1.14 "Return an iterator, currently self."
1.15
1.16 - return self
1.17 + return xrangeiterator(self)
1.18 +
1.19 +class xrangeiterator:
1.20 +
1.21 + "An iterator over an xrange."
1.22 +
1.23 + def __init__(self, obj):
1.24 +
1.25 + "Initialise the iterator with the given 'obj'."
1.26 +
1.27 + self.start = obj.start
1.28 + self.end = obj.end
1.29 + self.step = obj.step
1.30 + self.current = obj.start
1.31
1.32 def next(self):
1.33
1.34 "Return the next item or raise a StopIteration exception."
1.35
1.36 if self.step < 0 and self.current <= self.end or self.step > 0 and self.current >= self.end:
1.37 - raise StopIteration()
1.38 + raise StopIteration
1.39
1.40 current = self.current
1.41 self.current += self.step