summaryrefslogtreecommitdiff
path: root/Lib/whrandom.py
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>1994-08-01 11:34:53 +0000
committerGuido van Rossum <guido@python.org>1994-08-01 11:34:53 +0000
commitb6775db241f5fe5e3dc2ca09fc6c9e6164d4b2af (patch)
tree9362939305b2d088b8f19a530c9015d886bc2801 /Lib/whrandom.py
parent2979b01ff88ac4c5b316d9bf98edbaaaffac8e24 (diff)
downloadcpython-git-b6775db241f5fe5e3dc2ca09fc6c9e6164d4b2af.tar.gz
Merge alpha100 branch back to main trunk
Diffstat (limited to 'Lib/whrandom.py')
-rw-r--r--Lib/whrandom.py14
1 files changed, 4 insertions, 10 deletions
diff --git a/Lib/whrandom.py b/Lib/whrandom.py
index c7881b551b..670ca7a911 100644
--- a/Lib/whrandom.py
+++ b/Lib/whrandom.py
@@ -35,31 +35,25 @@ class whrandom:
# Without arguments, initialize from current time.
# With arguments (x, y, z), initialize from them.
#
- def __init__(self, *xyz):
- if not xyz:
+ def __init__(self, x = None, y = None, z = None):
+ if x is None:
# Initialize from current time
import time
t = int(time.time())
t, x = divmod(t, 256)
t, y = divmod(t, 256)
t, z = divmod(t, 256)
- else:
- # Initialize from arguments (x, y, z)
- x, y, z = xyz
self.seed(x, y, z)
#
# Set the seed from (x, y, z).
# These must be integers in the range [0, 256).
#
- def seed(self, *xyz):
- if type(xyz) <> type(()) or len(xyz) <> 3:
- raise TypeError, '3 seeds required'
- x, y, z = xyz
+ def seed(self, x, y, z):
if not type(x) == type(y) == type(z) == type(0):
raise TypeError, 'seeds must be integers'
if not 0 <= x < 256 and 0 <= y < 256 and 0 <= z < 256:
raise ValueError, 'seeds must be in range(0, 256)'
- self._seed = xyz
+ self._seed = (x, y, z)
#
# Get the next random number in the range [0.0, 1.0).
#