Am 03.03.2010 04:51, schrieb Lie Ryan:
import itertools
def gen():
     valid_chars = 'abcdefghijklmnopqrstuvwxyz'
     for char in itertools.repeat(valid_chars):
         yield char

gen = gen()
def gen_rand_string(length):
     chars = (next(gen) for i in range(length))
     return ''.join(chars)

since it gives me a perfect distribution of letters,

It does not. Only if not (length(valid_chars) % length)

Regards,
Michael
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to