Staging
v0.5.1
https://github.com/python/cpython
Revision 5bd919b6d7feed1ba3a89098accf80ffe9e1e490 authored by Guido van Rossum on 08 October 1997, 15:26:56 UTC, committed by Guido van Rossum on 08 October 1997, 15:26:56 UTC
1 parent b189a2f
Raw File
Tip revision: 5bd919b6d7feed1ba3a89098accf80ffe9e1e490 authored by Guido van Rossum on 08 October 1997, 15:26:56 UTC
Include macbuildno.h here (mac only) (Jack)
Tip revision: 5bd919b
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