[NCLUG] Python access to libc rand() (was: Python v.s. Ruby, and PRNGs)
Sean Reifschneider
jafo at tummy.com
Sun Apr 13 15:34:16 MDT 2008
>Sean is looking into /dev/random numbers. I also wanted to try the C
>library's rand() function, but it seems like that isn't currently exposed
import ctypes
from ctypes.util import find_library
libc = ctypes.CDLL(find_library('c'))
print libc.rand()
Note that RAND_MAX is not exposed, looks like it might be 2147483647 even
on 64-bit installs.
Sean
--
"Sometimes Omaha can't be avoided."
-- Howard Borden the navigator, _Bob_Newhart_
Sean Reifschneider, Member of Technical Staff <jafo at tummy.com>
tummy.com, ltd. - Linux Consulting since 1995: Ask me about High Availability
More information about the NCLUG
mailing list