Skip to content

Instantly share code, notes, and snippets.

@cwidmer
Created December 5, 2013 20:35
Show Gist options
  • Select an option

  • Save cwidmer/7813411 to your computer and use it in GitHub Desktop.

Select an option

Save cwidmer/7813411 to your computer and use it in GitHub Desktop.
generates a random sequence of length over alphabet
def rand_seq(alphabet, length):
"""
generates a random sequence of length over alphabet
@param alphabet: alphabet from which to choose characters
@type alphabet: list<str>
@param length: length of random string
@type length: int
"""
for c in alphabet:
if len(c)>1:
print "warning: individual tokens of length > 1: " + c
seq = "".join([random.choice(alphabet) for j in range(length)])
return seq
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment