Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #46297

Re: Output from to_bytes

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.glorb.com!news.linkpendium.com!news.linkpendium.com!panix!not-for-mail
From Grant Edwards <invalid@invalid.invalid>
Newsgroups comp.lang.python
Subject Re: Output from to_bytes
Date Tue, 28 May 2013 15:35:19 +0000 (UTC)
Organization PANIX Public Access Internet and UNIX, NYC
Lines 22
Message-ID <ko2irn$9oh$1@reader1.panix.com> (permalink)
References <knstkh$74a$1@news.albasani.net>
NNTP-Posting-Host dsl.comtrol.com
X-Trace reader1.panix.com 1369755319 10001 64.122.56.22 (28 May 2013 15:35:19 GMT)
X-Complaints-To abuse@panix.com
NNTP-Posting-Date Tue, 28 May 2013 15:35:19 +0000 (UTC)
User-Agent slrn/1.0.1 (Linux)
Xref csiph.com comp.lang.python:46297

Show key headers only | View raw


On 2013-05-26, Mok-Kong Shen <mok-kong.shen@t-online.de> wrote:
> I don't understand why with the code:
>
>     for k in range(8,12,1):
>       print(k.to_bytes(2,byteorder='big'))
>
> one gets the following output:
>
>     b'\x00\x08'
>     b'\x00\t'
>     b'\x00\n'
>     b'\x00\x0b'
>
> I mean the 2nd and 3rd should be b'\x00\x09' and b'x00\x0a'.
> Anyway, how could I get the output in the forms I want?

Well, it would help if you told us what output form you want.

-- 
Grant Edwards               grant.b.edwards        Yow! I'm gliding over a
                                  at               NUCLEAR WASTE DUMP near
                              gmail.com            ATLANTA, Georgia!!

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Output from to_bytes Mok-Kong Shen <mok-kong.shen@t-online.de> - 2013-05-26 14:02 +0200
  Re: Output from to_bytes Chris Angelico <rosuav@gmail.com> - 2013-05-26 23:26 +1000
  Re: Output from to_bytes Terry Jan Reedy <tjreedy@udel.edu> - 2013-05-26 16:45 -0400
  Re: Output from to_bytes Grant Edwards <invalid@invalid.invalid> - 2013-05-28 15:35 +0000
    Re: Output from to_bytes Mok-Kong Shen <mok-kong.shen@t-online.de> - 2013-06-02 21:09 +0200
      Re: Output from to_bytes Ned Batchelder <ned@nedbatchelder.com> - 2013-06-02 18:18 -0400

csiph-web