1.1 --- a/lib/__builtins__/span.py Sat Mar 25 16:41:06 2017 +0100
1.2 +++ b/lib/__builtins__/span.py Sat Mar 25 17:23:35 2017 +0100
1.3 @@ -73,7 +73,12 @@
1.4
1.5 "Return the length of the range."
1.6
1.7 - return (self.end - self.start) / self.step
1.8 + n = (self.end - self.start) / self.step
1.9 + last = self.start + (n * self.step)
1.10 + if last == self.end:
1.11 + return n
1.12 + else:
1.13 + return n + 1
1.14
1.15 def __iter__(self):
1.16
2.1 --- a/tests/range.py Sat Mar 25 16:41:06 2017 +0100
2.2 +++ b/tests/range.py Sat Mar 25 17:23:35 2017 +0100
2.3 @@ -59,3 +59,9 @@
2.4 double = xrange(3, 5, 1)
2.5 print list(double) # [3, 4]
2.6 print reduce(lambda x, y: x+y, double) # [7]
2.7 +
2.8 +# Test steps not coinciding with the end.
2.9 +
2.10 +beyond = xrange(4, 9, 2)
2.11 +print list(beyond) # [4, 6, 8]
2.12 +print len(beyond) # 3