Module randomorg
source code
Module to access random.org for random numbers
Examples
Dice
>>> import randomorg
>>> ro = randomorg.RandomOrg()
>>> if ro.checkQuota():
...:
...: print ro.getInteger(2, 1, 6)
Feed /dev/random
>>> import os
>>> import randomorg
>>> rfp = "/dev/random"
>>> ro = randomorg.RandomOrg()
>>>
>>> if os.access(rfp, os.W_OK):
...: fp = open(rfp, "a")
...:
...: if ro.checkBuffer():
...: for bytes in ro.getRandomByte():
...: fp.write(bytes)
...: close(fp)
Version:
0.01
Author:
Ali Polatel <polatel@itu.edu.tr>
License:
GPL-3
|
Get an url, raise RandomOrgHTTPError on failure.
- Parameters:
uri (str) - The requested url address.
headers (dict) - HTTP Headers passed to urllib2.Request()
|