Staging
v0.5.1
https://github.com/python/cpython
Raw File
Tip revision: cf6fc7906d5abb6e0b9e7e52c94e8b28883672f7 authored by cvs2svn on 05 August 2004, 07:21:01 UTC
This commit was manufactured by cvs2svn to create tag 'r24a2'.
Tip revision: cf6fc79
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