str() should convert ANY object to a string without EXCEPTIONS !

Roy Smith roy at
Sun Sep 28 15:25:56 CEST 2008

In article <00ef327d$0$20666$c3e8da3 at>,
 Steven D'Aprano <steve at> wrote:

> from random import randint
> ''.join(chr(randint(0, 255)) for i in xrange(len(input)))
> of course. How else should you get random bytes? :)

That a UUOL (Useless Usage Of Len; by analogy to UUOC).  This works just as 

''.join(chr(randint(0, 255)) for i in input)

More information about the Python-list mailing list