annotate Lib/rand.py @ 4566:6403c94de50d
legacy-trunk
Added safeguard against failure in __del__.
| author |
Guido van Rossum <guido@python.org> |
| date |
Wed, 27 Nov 1996 19:39:58 +0000 |
| parents |
b29696e5c4d9 |
| children |
|
| rev |
line source |
|
5
|
1 # Module 'rand'
|
|
362
|
2 # Don't use unless you want compatibility with C's rand()!
|
|
5
|
3
|
|
|
4 import whrandom
|
|
|
5
|
|
|
6 def srand(seed):
|
|
|
7 whrandom.seed(seed%256, seed/256%256, seed/65536%256)
|
|
|
8
|
|
|
9 def rand():
|
|
|
10 return int(whrandom.random() * 32768.0) % 32768
|
|
|
11
|
|
|
12 def choice(seq):
|
|
|
13 return seq[rand() % len(seq)]
|