[Tutor] os.urandom()

On Sat, Aug 7, 2010 at 17:00, Alan Gauld <alan.gauld at btinternet.com> wrote:
>> "Richard D. Moores" <rdmoores at gmail.com> wrote
>>> Yes, the number of bytes seems to <= 6, or is it?:
>>>>>>>>>> os.urandom(6)
>>>> b'\xf1\x1c\x15\x83\x14\x0e'
>> ok
>>>>>> os.urandom(6)
>>>> b'l\xbb\xae\xb7\x0ft'
>> still ok - the l and t at the ends are valid characters so Python
> prints the letter
>>> hex(ord('t'))
'0x74'
>>> hex(ord('l'))
'0x6c'
So if os.urandom() had been written so that it printed only hex,
b'l\xbb\xae\xb7\x0ft' would have been
b'\x6c\xbb\xae\xb7\x0f\x74' , right?
Thanks very much for that, Alan.
How were we supposed to know that all the hexes have 2 digits? How did you?
Dick