Staging
v0.5.1
https://github.com/python/cpython
Revision 5bd85d93c4808935eb3cc3490a0d080e7e727ab7 authored by Jack Jansen on 23 August 1996, 15:45:26 UTC, committed by Jack Jansen on 23 August 1996, 15:45:26 UTC
1 parent 27b10ec
Raw File
Tip revision: 5bd85d93c4808935eb3cc3490a0d080e7e727ab7 authored by Jack Jansen on 23 August 1996, 15:45:26 UTC
Always call __initialize(), also on PPC
Tip revision: 5bd85d9
rand.py
# Module 'rand'
# Don't use unless you want compatibility with C's rand()!

import whrandom

def srand(seed):
	whrandom.seed(seed%256, seed/256%256, seed/65536%256)

def rand():
	return int(whrandom.random() * 32768.0) % 32768

def choice(seq):
	return seq[rand() % len(seq)]
back to top