[Tutor] os.urandom()

Richard D. Moores rdmoores at gmail.com
Mon Aug 9 06:14:32 CEST 2010

On Sun, Aug 8, 2010 at 08:11, bob gailer <bgailer at gmail.com> wrote:
> On 8/8/2010 1:57 AM, Richard D. Moores wrote:

>> How were we supposed to know that all the hexes have 2 digits?
> In version 2.6.5 Language Reference 2.4.1 - String literals:
> \xhh Character with hex value hh

>>> os.urandom(6)

In my Active Python 3.1 docs, Language Ref 2.4.1. String and Bytes
literals, I have

The same as what you quoted, plus a couple of footnotes:
\xhh Character with hex value hh (2,3)

That footnote 2, "Unlike in Standard C, at most two hex digits are
accepted.", seems necessary; otherwise that \x138a could be seen by my
former, byte-ignorant self as a \xhhhh, and puzzled about why I got
only 4 bytes, not 6.  :)

But I never would have thought to have looked in the docs where you did.


More information about the Tutor mailing list