Added a function for creating a non repeating random list of number.

This commit is contained in:
Zachary Pavlov 2005-07-15 21:28:54 +00:00
parent d8bb04a3f8
commit 565cce77e5
1 changed files with 14 additions and 2 deletions

View File

@ -50,7 +50,19 @@ def indent(stream, numIndents, str):
stream.write(' ' * numIndents + str)
def nonRepeatingRandomList(vals,max):
random.seed(time.time())
#first generate a set of random values
valueList=range(max)
finalVals=[]
for i in range(vals):
index=int(random.random()*len(valueList))
finalVals.append(valueList[index])
valueList.remove(valueList[index])
return finalVals
def writeFsmTree(instance, indent = 0):
if hasattr(instance, 'parentFSM'):
writeFsmTree(instance.parentFSM, indent-2)
@ -62,7 +74,7 @@ def writeFsmTree(instance, indent = 0):
if __debug__:
class StackTrace:
def __init__(self, label="", start=0, limit=None):