Dick Moores wrote: > "urandom(n) > > Return a string of n random bytes suitable for cryptographic use. > This function returns random bytes from an OS-specific randomness > source. The returned data should be unpredictable enough for > cryptographic applications, though its exact quality depends on the > OS implementation. On a UNIX-like system this will query > /dev/urandom, and on Windows it will use CryptGenRandom. If a > randomness source is not found, NotImplementedError will be raised. > New in version 2.4." > > >>> from os import urandom > >>> urandom(10) > '[EMAIL PROTECTED]'
It's a string where each character (byte) is selected randomly from the range 0-255. In Python a string can be used as a container for arbitrary byte values that are not text and maybe don't fit your notion of what a string is. When the Python interpreter prints a value automatically (not as the result of an explicit print) as above, it prints repr(value). For a string s, repr(s) uses \x escapes to display any non-printable characters. So what you see above is the repr() of a string whose first bytes contain the values (in hexadecimal) c0 f0 ea 0c dd 95 75 == ord('u') so it prints as 'u' rather than \x75 40 == ord('@') 5a == ord('Z') 89 HTH, Kent _______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor