Forums

Seeding random numbers

Hi. seed with no arguments fails with something about too many open files.

Can you provide a bit more info about what you were doing, and what the error was?

Hi. You should see the error if you write and run this program in Python 3:

from random import seed
seed()

That works fine for me. Exactly what error message are you seeing?

Did you run it in Python 3?

OSError: [Errno 24] Too many open files

I just tried it in Python 3.3.6 and in 3.4.0 -- no errors in either case.

The random.seed() function may well be trying to access a file (the best source of random numbers in Linux is the pseudo-file /dev/random) so you might get that error if you had a very large number of files open in your process through some other code in your process. Were you running this code as part of a larger script?