truly_random.py --- A random number generator that returns truly random numbers. Danny Yoo (dyoo@hkn.eecs.berkeley.edu), with help from the kind folks at Python-tutor: http://mail.python.org/mailman/listinfo/tutor Special thanks to Gregor Lingl, Tim Peters, Derrick Hudson, and Sean Perry. INSTALLATION: To install this package, the command: python setup.py install should do it. EXAMPLE USAGE: >>> import truly_random >>> truly_random.random() 0.27969009844631798 >>> truly_random.choice('aeiou') 'e' >>> truly_random.choice('aeiou') 'i' >>> truly_random.set_default_as_fourmi() >>> truly_random.choice('aeiou') 'u' HISTORY: To see how this module was born, we can browse through the thread here: http://mail.python.org/pipermail/tutor/2002-July/015581.html DESCRIPTION: truly_random should have the same interface as the 'random' module in the standard library: http://www.python.org/doc/lib/module-random.html But just replace the word "pseudo" with "real". This module can use different sources for random bits. I've included three of them: 1. Fourmilab: http://www.fourmilab.ch/cgi-bin/uncgi/Hotbits This was the motivating example for writing this module. By the way, we probably shouldn't use Fourmilab too much, since Fourmilab does have a quota on the number of bits one is allows to pull from it. 2. /dev/random Another is the '/dev/random' device found on Unix systems. This is the default source we use for random bits. 3. pseudorandom: Finally, we have a test BitSource that uses pseudorandom numbers. This isn't truly random. To switch bit sources, we provide the following functions: set_default_as_dev_random() set_default_as_fourmi() set_default_as_pseudorandom()