Prev: ANN: Leo 4.7 final released
Next: AKKA vs Python
From: Michael Rudolf on 3 Mar 2010 10:15 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 |