s=ascii(hexlify(urandom(10)))

Discussion in 'Python' started by gert, Jan 17, 2009.

  1. gert

    gert Guest

    I expected that py3 did not converted the b'...' indication too ?

    b'afc76815e3fc429fa9d7'
     
    gert, Jan 17, 2009
    #1
    1. Advertising

  2. > I expected that py3 did not converted the b'...' indication too ?
    >
    > b'afc76815e3fc429fa9d7'


    You mean, just because you invoked the ascii() builtin, the b
    prefix should disappear? Re-read the documentation of the
    ascii() builtin - it probably does something completely different
    from what you expect it to do.

    Regards,
    Martin
     
    Martin v. Löwis, Jan 17, 2009
    #2
    1. Advertising

  3. gert

    gert Guest

    On Jan 17, 9:08 pm, "Martin v. Löwis" <> wrote:
    > > I expected that py3 did not converted the b'...' indication too ?

    >
    > > b'afc76815e3fc429fa9d7'

    >
    > You mean, just because you invoked the ascii() builtin, the b
    > prefix should disappear? Re-read the documentation of the
    > ascii() builtin - it probably does something completely different
    > from what you expect it to do.


    s = str(hexlify(urandom(8)))[2:18]
     
    gert, Jan 17, 2009
    #3
  4. gert wrote:
    > On Jan 17, 9:08 pm, "Martin v. Löwis" <> wrote:
    >>> I expected that py3 did not converted the b'...' indication too ?
    >>> b'afc76815e3fc429fa9d7'

    >> You mean, just because you invoked the ascii() builtin, the b
    >> prefix should disappear? Re-read the documentation of the
    >> ascii() builtin - it probably does something completely different
    >> from what you expect it to do.

    >
    > s = str(hexlify(urandom(8)))[2:18]


    And your question is?
     
    Martin v. Löwis, Jan 17, 2009
    #4
  5. gert

    gert Guest

    On Jan 18, 12:05 am, "Martin v. Löwis" <> wrote:
    > gert wrote:
    > > On Jan 17, 9:08 pm, "Martin v. Löwis" <> wrote:
    > >>> I expected that py3 did not converted the b'...' indication too ?
    > >>> b'afc76815e3fc429fa9d7'
    > >> You mean, just because you invoked the ascii() builtin, the b
    > >> prefix should disappear? Re-read the documentation of the
    > >> ascii() builtin - it probably does something completely different
    > >> from what you expect it to do.

    >
    > > s = str(hexlify(urandom(8)))[2:18]

    >
    > And your question is?


    No question just solution to get rit of b'' :)
     
    gert, Jan 17, 2009
    #5
  6. "Martin v. Löwis" <> wrote:

    > > On Jan 17, 9:08 pm, "Martin v. Löwis" <> wrote:
    > >>> I expected that py3 did not converted the b'...' indication too ?
    > >>> b'afc76815e3fc429fa9d7'
    > >> You mean, just because you invoked the ascii() builtin, the b
    > >> prefix should disappear? Re-read the documentation of the
    > >> ascii() builtin - it probably does something completely different
    > >> from what you expect it to do.

    > >
    > > s = str(hexlify(urandom(8)))[2:18]

    >
    > And your question is?


    The answer is probably 23.

    --
    Pierre-Alain Dorange

    Ce message est sous licence Creative Commons "by-nc-sa-2.0"
    <http://creativecommons.org/licenses/by-nc-sa/2.0/fr/>
     
    Pierre-Alain Dorange, Jan 17, 2009
    #6
  7. >>> s = str(hexlify(urandom(8)))[2:18]
    >> And your question is?

    >
    > No question just solution to get rit of b'' :)


    Ah. hexlify(urandom(8)).decode('ascii')

    Regards,
    Martin
     
    Martin v. Löwis, Jan 17, 2009
    #7
  8. gert

    gert Guest

    On Jan 18, 12:20 am, "Martin v. Löwis" <> wrote:
    > >>> s = str(hexlify(urandom(8)))[2:18]
    > >> And your question is?

    >
    > > No question just solution to get rit of b'' :)

    >
    > Ah. hexlify(urandom(8)).decode('ascii')


    Ok that one looks better then mine :)
     
    gert, Jan 17, 2009
    #8
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Grzegorz Smith

    trying to get hash from os.urandom

    Grzegorz Smith, Jan 23, 2006, in forum: Python
    Replies:
    2
    Views:
    966
    Robert Kern
    Jan 23, 2006
  2. Ron Peterson

    /dev/urandom vs. /dev/random

    Ron Peterson, Jan 7, 2005, in forum: C Programming
    Replies:
    21
    Views:
    1,610
    Keith Thompson
    Jan 13, 2005
  3. Jonas Galvez

    hexlify and unhexlify

    Jonas Galvez, Jun 29, 2005, in forum: Ruby
    Replies:
    1
    Views:
    653
    nobuyoshi nakada
    Jun 29, 2005
  4. Mike Boone
    Replies:
    0
    Views:
    158
    Mike Boone
    Dec 22, 2007
  5. Michele Dondi
    Replies:
    1
    Views:
    167
    Anno Siegel
    Feb 22, 2004
Loading...

Share This Page