Path: csiph.com!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder2.hal-mli.net!newsfeed.xs4all.nl!newsfeed3.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.024 X-Spam-Evidence: '*H*': 0.95; '*S*': 0.00; 'string.': 0.05; 'binary': 0.07; 'interpreter.': 0.07; 'string': 0.09; 'subject:few': 0.09; 'python': 0.11; 'creates': 0.14; 'fiddle': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'number?': 0.16; 'wrote:': 0.18; 'thu,': 0.19; 'seems': 0.21; '>>>': 0.22; 'header:In-Reply-To:1': 0.27; 'point': 0.28; 'chris': 0.29; 'message-id:@mail.gmail.com': 0.30; "skip:' 10": 0.31; '13,': 0.31; '>>>>': 0.31; "d'aprano": 0.31; 'steven': 0.31; 'but': 0.35; 'received:google.com': 0.35; 'doing': 0.36; 'wrong': 0.37; 'expected': 0.38; 'to:addr:python-list': 0.38; 'fact': 0.38; 'pm,': 0.38; 'rather': 0.38; 'to:addr:python.org': 0.39; 'how': 0.40; 'flat': 0.60; 'simple': 0.61; 'fact,': 0.69; 'receive': 0.70; '8bit%:100': 0.72; '10:11': 0.84; 'embraced': 0.84; 'skip:\xef 10': 0.84; '2013': 0.98 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type:content-transfer-encoding; bh=PDk4iZSDOb5/FH7kfftdWMxPgpQTxhCAtIgBq5Epq84=; b=oosX75H9zmynsKmq6NeXvPzqqb43wsQfU85n5Yox42OPyFq/leShjx5YuVOKlvRUSq B4ZIfswtBVeYImuZFFftpXQID0sF+3EPFc0o+f08ek6CzXWi7KsJaU8c/XP8EVmLKohK DKjlt+/sNjew08L/nhG+0nISI2/59HJHY6fPYJ9RS//oXycIYyKcI2XqNE32y23fol6S MDRwBEsiev+EUaHY0lRtAMId/9Zrf9Llw/1SDkoigOpkenGl3zPm0mcgLIa66pgs59L6 aBY0C8qgKSQNpxIkvZcyx1380xXHP19SPP5nr4IzsenpticDN5/zTBJvuMPWJKgJ3U1I 5ahw== MIME-Version: 1.0 X-Received: by 10.52.164.163 with SMTP id yr3mr9363458vdb.76.1371111638484; Thu, 13 Jun 2013 01:20:38 -0700 (PDT) In-Reply-To: References: <6dfa3707-80f4-407a-a109-66dbb0130513@googlegroups.com> <51b83e5a$0$29998$c3e8da3$5496439d@news.astraweb.com> <51b90ead$0$29997$c3e8da3$5496439d@news.astraweb.com> <51b9708b$0$29872$c3e8da3$5496439d@news.astraweb.com> Date: Thu, 13 Jun 2013 18:20:38 +1000 Subject: Re: A few questiosn about encoding From: Chris Angelico To: python-list@python.org Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable 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: 42 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1371111646 news.xs4all.nl 15887 [2001:888:2000:d::a6]:51450 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:47923 On Thu, Jun 13, 2013 at 6:08 PM, =CE=9D=CE=B9=CE=BA=CF=8C=CE=BB=CE=B1=CE=BF= =CF=82 =CE=9A=CE=BF=CF=8D=CF=81=CE=B1=CF=82 wrote: > On 13/6/2013 10:58 =CF=80=CE=BC, Chris Angelico wrote: >> >> On Thu, Jun 13, 2013 at 5:42 PM, =EF=BF=BD=EF=BF=BD=EF=BF=BD=EF=BF=BD=EF= =BF=BD=EF=BF=BD=EF=BF=BD=EF=BF=BD =EF=BF=BD=EF=BF=BD=EF=BF=BD=EF=BF=BD=EF= =BF=BD=EF=BF=BD >> wrote: >> >>> On 13/6/2013 10:11 =EF=BF=BD=EF=BF=BD, Steven D'Aprano wrote: >>>> >>>> No! That creates a string from 16474 in base two: >>>> '0b100000001011010' >>> >>> >>> I disagree here. >>> 16474 is a number in base 10. Doing bin(16474) we get the binary >>> representation of number 16474 and not a string. >>> Why you say we receive a string while python presents a binary number? >> >> >> You can disagree all you like. Steven cited a simple point of fact, >> one which can be verified in any Python interpreter. Nikos, you are >> flat wrong here; bin(16474) creates a string. > > > Indeed python embraced it in single quoting '0b100000001011010' and not a= s > 0b100000001011010 which in fact makes it a string. > > But since bin(16474) seems to create a string rather than an expected > number(at leat into my mind) then how do we get the binary representation= of > the number 16474 as a number? In Python 2: >>> 16474 In Python 3, you have to fiddle around with ctypes, but broadly speaking, the same thing. ChrisA