Staging
v0.8.1
https://github.com/python/cpython
Raw File
Tip revision: 8022feed57dfb3ef54771fcf752f8ae85a28635f authored by Anthony Baxter on 18 October 2006, 07:02:36 UTC
regenerating tag.
Tip revision: 8022fee
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