From: Michael Rudolf on
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
First  |  Prev  | 
Pages: 1 2 3 4 5 6 7 8 9 10 11
Prev: ANN: Leo 4.7 final released
Next: AKKA vs Python