[CentralOH] random.seed

Mark Erbaugh mark at microenh.com
Mon Mar 2 15:55:29 CET 2009


I've written a Python program that generates tests and answer keys from
a pool of questions.  It uses random.seed with a user entered value so
that the user can regenerate the same test sequence if needed.

This morning, I discovered that the same seed doesn't produce the same
random values on 32-bit and 64-bit systems.

I think the problem is that hash(<str>) generates different values on
the 32 and 64 bit systems. I found that by using 

random.seed(hash(<str>) & 0xffffffff)

I can get the same results.  Is there a better way? Is my way "safe" and
repeatable?

Mark



More information about the CentralOH mailing list