summaryrefslogtreecommitdiffstats
path: root/Demo/classes/Range.py
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>1993-12-17 14:23:52 (GMT)
committerGuido van Rossum <guido@python.org>1993-12-17 14:23:52 (GMT)
commit7565b934144012f25e8b22d888572c048f0eb21a (patch)
tree1fe49e0e20f1201f97eb13596ef3c5f014d8182a /Demo/classes/Range.py
parent3cbc16d9041fe1fa87356bdacc2f1ad52fb99a89 (diff)
downloadcpython-7565b934144012f25e8b22d888572c048f0eb21a.zip
cpython-7565b934144012f25e8b22d888572c048f0eb21a.tar.gz
cpython-7565b934144012f25e8b22d888572c048f0eb21a.tar.bz2
*** empty log message ***
Diffstat (limited to 'Demo/classes/Range.py')
-rwxr-xr-xDemo/classes/Range.py5
1 files changed, 2 insertions, 3 deletions
diff --git a/Demo/classes/Range.py b/Demo/classes/Range.py
index b8bc9be..e7b6be2 100755
--- a/Demo/classes/Range.py
+++ b/Demo/classes/Range.py
@@ -16,7 +16,7 @@ def range(*a):
start, stop, step = a
else:
raise TypeError, 'range() needs 1-3 arguments'
- return Range().init(start, stop, step)
+ return Range(start, stop, step)
# Class implementing a range object.
@@ -26,14 +26,13 @@ def range(*a):
class Range:
# initialization -- should be called only by range() above
- def init(self, start, stop, step):
+ def __init__(self, start, stop, step):
if step == 0:
raise ValueError, 'range() called with zero step'
self.start = start
self.stop = stop
self.step = step
self.len = max(0, int((self.stop - self.start) / self.step))
- return self
# implement `x` and is also used by print x
def __repr__(self):