I read in a book that /dev/random is like an infinite file, but when I set up the following codes to see what the content look like, it prints nothing.
with open("/dev/random") as f:
for i in xrange(10):
print f.readline()
BTW, when I tried this with /dev/urandom, it worked.
It is outputting random bytes, not random lines. You see nothing until you get a newline, which will only happen every 256 bytes on average. The reason
/dev/urandomappears to work is simply that it operates faster. Wait longer, read less, or use/dev/urandom.