Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed1.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.086 X-Spam-Evidence: '*H*': 0.83; '*S*': 0.00; 'bytes,': 0.09; 'subject:How': 0.10; 'missed': 0.12; '10:45': 0.16; ':-(': 0.16; 'received:74.208.4.195': 0.16; 'wrote:': 0.18; '>>>': 0.22; 'header:User-Agent:1': 0.23; 'mon,': 0.24; 'header:In-Reply-To:1': 0.27; 'am,': 0.29; 'too.': 0.31; "d'aprano": 0.31; 'steven': 0.31; 'probably': 0.32; 'subject:from': 0.34; "can't": 0.35; 'but': 0.35; 'sequence': 0.36; 'next': 0.36; 'too': 0.37; 'to:addr :python-list': 0.38; 'pm,': 0.38; 'to:addr:python.org': 0.39; 'how': 0.40; 'negative': 0.60; 'believe': 0.68; 'received:74.208': 0.68; 'subject:get': 0.81; 'batchelder': 0.84; '2013': 0.98 Date: Mon, 27 May 2013 20:41:59 -0400 From: Dave Angel User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130510 Thunderbird/17.0.6 MIME-Version: 1.0 To: python-list@python.org Subject: Re: How to get an integer from a sequence of bytes References: <51a3faca$0$29966$c3e8da3$5496439d@news.astraweb.com> In-Reply-To: <51a3faca$0$29966$c3e8da3$5496439d@news.astraweb.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Provags-ID: V02:K0:3ys4SnhU1i4DhFfYSiKzDr8stv/P7EfWa4+TRtSTsQS z337VSYznwkZ9UdOt16Vdmo/X4xd4H6+ZS/diHJfZHJZ/Clw4J bi8FsmU64BW5T5+8li0Mx6JBYqAfFnzILFM29Tlb+uylSxg0ki /sTznVpmQf13k5vS1Y150E4NGx97VHLn8IBtD3JZ0bxgO/cmbe EtsLZma836NSTGxM32JcW/eLNoAm5kYjiDXArrB0rPVaiSKR3T UVEH3Tjc/5y1iPDDnJ1PeCf5ITpKf4bANoWBXKtRUWf4bU+HYy KK48K5iDHQoiHo3K4Q0/E77cEZt3zSwu0jQ3W98BYmL9PvDD9Z Kzxl5Sf2Z1S45Ka5Hmxs= X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 18 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1369701741 news.xs4all.nl 15871 [2001:888:2000:d::a6]:47852 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:46238 On 05/27/2013 08:31 PM, Steven D'Aprano wrote: > On Mon, 27 May 2013 11:30:18 -0400, Ned Batchelder wrote: > >> On 5/27/2013 10:45 AM, Mok-Kong Shen wrote: >>> From an int one can use to_bytes to get its individual bytes, but how >>> can one reconstruct the int from the sequence of bytes? >>> >>> >> The next thing in the docs after int.to_bytes is int.from_bytes: > > And I can't believe I missed that too :-( > > And that approach probably works for negative ints too. -- DaveA