Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.freenet.ag!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!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.003 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'programmer': 0.03; 'represents': 0.05; 'that?': 0.05; 'column': 0.07; 'subject:few': 0.09; 'cc:addr:python-list': 0.11; '(11': 0.16; '16)': 0.16; 'benjamin': 0.16; 'better:': 0.16; 'decimal.': 0.16; 'gpg': 0.16; 'hex': 0.16; 'hexadecimal': 0.16; 'lowercase': 0.16; 'ordinal': 0.16; 'programmer,': 0.16; 'url:decimal': 0.16; 'url:lmgtfy': 0.16; 'sat,': 0.16; 'wrote:': 0.18; 'cc:addr:python.org': 0.22; 'cc:2**1': 0.23; 'byte': 0.24; 'char': 0.24; "shouldn't": 0.24; 'cc:no real name:2**0': 0.24; '15,': 0.26; 'this:': 0.26; 'least': 0.26; 'header:In-Reply-To:1': 0.27; 'message-id:@mail.gmail.com': 0.30; "i'm": 0.30; 'url:mailman': 0.30; 'gives': 0.31; '>>>>': 0.31; 'decimal': 0.31; 'easy,': 0.31; 'so-called': 0.31; 'open': 0.33; 'url:python': 0.33; 'convert': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'sequence': 0.36; 'url:listinfo': 0.36; "didn't": 0.36; 'url:org': 0.36; 'should': 0.36; 'pm,': 0.38; 'url:mail': 0.40; 'how': 0.40; 'tell': 0.60; 'numbers': 0.61; 'browser': 0.61; 'from:charset:utf-8': 0.61; 'first': 0.61; 'personal': 0.63; 'click': 0.77; 'brain,': 0.84; 'it\xe2\x80\x99s': 0.84; 'url:tk': 0.95; '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:from:date:message-id:subject:to :cc:content-type:content-transfer-encoding; bh=+ooUdFAb/t827Fyy4NevniqapfMLQzXGEVFMjWjar7w=; b=GsbcgSDndBTBDp0l5mkFcKGxiRgzRZoqkNj8VV3jwtHjVJIrCy42pOIy/G6fgObSBR dYHzvXxDDglwJHUN6tQOuyF6s2vTvQn6ln5h20KJsdGP0+5ZkkCbiAblB/GSywfXpiD6 CD6V9y4VAjsHX9yB42Hptr4hlDRSa8XHEXCyz0dN7te9prlWuK98/O5LMM8sNuSd+xcn UKSBrIVsWKpIbPYFHANQ7SOyKphSzInS3IR5vr70HfmD6aHk3vCZMymeIQR5XQ4F0jJU n5ipjWeD/OqCuEoObmeIPfl1p3FWvoQSWNN9yh9SNq45DRVRhhl0zbEC7A8RFQzzXWa6 660w== X-Received: by 10.50.23.8 with SMTP id i8mr2920544igf.42.1371390370067; Sun, 16 Jun 2013 06:46:10 -0700 (PDT) MIME-Version: 1.0 In-Reply-To: <7DD56BB4-A7B2-4A48-961A-03065A349995@schollnick.net> References: <7DD56BB4-A7B2-4A48-961A-03065A349995@schollnick.net> From: =?UTF-8?B?Q2hyaXMg4oCcS3dwb2xza2HigJ0gV2Fycmljaw==?= Date: Sun, 16 Jun 2013 15:45:50 +0200 Subject: Re: A few questiosn about encoding To: Benjamin Schollnick Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Cc: python-list@python.org, Nick the Gr33k 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: 67 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1371390373 news.xs4all.nl 15903 [2001:888:2000:d::a6]:41469 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:48451 On Sat, Jun 15, 2013 at 10:35 PM, Benjamin Schollnick wrote: > Nick, > > The only thing that i didn't understood is this line. > First please tell me what is a byte value > > \x1b is a sequence you find inside strings (and "byte" strings, the > b'...' format). > > > \x1b is a character(ESC) represented in hex format > > b'\x1b' is a byte object that represents what? > > >>>> chr(27).encode('utf-8') > b'\x1b' > >>>> b'\x1b'.decode('utf-8') > '\x1b' > > After decoding it gives the char ESC in hex format > Shouldn't it result in value 27 which is the ordinal of ESC ? > > > I'm sorry are you not listening? > > 1b is a HEXADECIMAL Number. As a so-called programmer, did you seriously > not consider that? > > Try this: > > 1) Open a Web browser > 2) Go to Google.com > 3) Type in "Hex 1B" > 4) Click on the first link > 5) In the Hexadecimal column find 1B. > > Or open your favorite calculator, and convert Hexadecimal 1B to Decimal > (Base 10). > > - Benjamin > > > > -- > http://mail.python.org/mailman/listinfo/python-list > Better: a programmer should know how to convert hexadecimal to decimal. 0x1B =3D (0x1 * 16^1) + (0xB * 16^0) =3D (1 * 16) + (11 * 1) =3D 16 + 11 = =3D 27 It=E2=80=99s that easy, and a programmer should be able to do that in their brain, at least with small numbers. Or at least know that: http://lmgtfy.com/?q=3D0x1B+in+decimal Or at least `hex(27)`; or '`{:X}'.format(27)`; or `'%X' % 27`. (I despise hex numbers with lowercase letters, but that=E2=80=99s my personal opinion.) -- Kwpolska | GPG KEY: 5EAAEA16 stop html mail | always bottom-post http://asciiribbon.org | http://caliburn.nl/topposting.html