From: Colin Patrick McCabe Date: Fri, 10 Feb 2012 06:00:27 +0000 (-0800) Subject: pickrand.py: seed RNG with process ID X-Git-Url: http://club.cc.cmu.edu/~cmccabe/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=fceef8f2454d64aec2fcb8f9cfd6e931b3ce034b;p=cmccabe-bin pickrand.py: seed RNG with process ID Seed the random number generator with the current process ID rather than with the clock. Signed-off-by: Colin McCabe --- diff --git a/pickrand.py b/pickrand.py index 558115c..6340971 100755 --- a/pickrand.py +++ b/pickrand.py @@ -20,7 +20,7 @@ for root, dirs, files in os.walk("."): allfiles.append(os.path.join(root, f)) if (len(allfiles) == 0): sys.exit(1) -random.seed(None) +random.seed(os.getpid()) r = random.randint(0,len(allfiles) - 1) print(allfiles[r]) if (print_to_stderr):