Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > s=ascii(hexlify(urandom(10)))

Reply
Thread Tools

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

 
 
gert
Guest
Posts: n/a
 
      01-17-2009
I expected that py3 did not converted the b'...' indication too ?

b'afc76815e3fc429fa9d7'

 
Reply With Quote
 
 
 
 
Martin v. Löwis
Guest
Posts: n/a
 
      01-17-2009
> 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
 
Reply With Quote
 
 
 
 
gert
Guest
Posts: n/a
 
      01-17-2009
On Jan 17, 9:08*pm, "Martin v. Löwis" <mar...@v.loewis.de> 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())[2:18]
 
Reply With Quote
 
Martin v. Löwis
Guest
Posts: n/a
 
      01-17-2009
gert wrote:
> On Jan 17, 9:08 pm, "Martin v. Löwis" <mar...@v.loewis.de> 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())[2:18]


And your question is?
 
Reply With Quote
 
gert
Guest
Posts: n/a
 
      01-17-2009
On Jan 18, 12:05*am, "Martin v. Löwis" <mar...@v.loewis.de> wrote:
> gert wrote:
> > On Jan 17, 9:08 pm, "Martin v. Löwis" <mar...@v.loewis.de> 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())[2:18]

>
> And your question is?


No question just solution to get rit of b''
 
Reply With Quote
 
Pierre-Alain Dorange
Guest
Posts: n/a
 
      01-17-2009
"Martin v. Löwis" <> wrote:

> > On Jan 17, 9:08 pm, "Martin v. Löwis" <mar...@v.loewis.de> 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())[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/>
 
Reply With Quote
 
Martin v. Löwis
Guest
Posts: n/a
 
      01-17-2009
>>> s = str(hexlify(urandom())[2:18]
>> And your question is?

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


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

Regards,
Martin
 
Reply With Quote
 
gert
Guest
Posts: n/a
 
      01-17-2009
On Jan 18, 12:20*am, "Martin v. Löwis" <mar...@v.loewis.de> wrote:
> >>> s = str(hexlify(urandom())[2:18]
> >> And your question is?

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

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


Ok that one looks better then mine
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off




Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57