Staging
v0.5.1
https://github.com/python/cpython
Revision dbaf332107b3188980c0bce6aed7ac6bce212ec7 authored by Guido van Rossum on 03 October 1994, 10:25:54 UTC, committed by Guido van Rossum on 03 October 1994, 10:25:54 UTC
1 parent ebea896
Raw File
Tip revision: dbaf332107b3188980c0bce6aed7ac6bce212ec7 authored by Guido van Rossum on 03 October 1994, 10:25:54 UTC
Jack's last version (now I'm supposed to get it working :-)
Tip revision: dbaf332
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