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


Groups > comp.lang.python > #46408

Re: python b'...' notation

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!xlned.com!feeder5.xlned.com!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <ian.g.kelly@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.035
X-Spam-Evidence '*H*': 0.93; '*S*': 0.00; 'steve': 0.09; 'character.': 0.16; 'hex': 0.16; 'notation': 0.16; 'subject:python': 0.16; 'thanks,': 0.17; 'wrote:': 0.18; 'wed,': 0.18; '>>>': 0.22; 'values': 0.27; 'header:In-Reply-To:1': 0.27; 'message-id:@mail.gmail.com': 0.30; "skip:' 10": 0.31; 'received:209.85': 0.35; 'except': 0.35; 'received:google.com': 0.35; 'received:209': 0.37; 'displays': 0.38; 'to:addr:python- list': 0.38; 'pm,': 0.38; 'to:addr:python.org': 0.39; 'how': 0.40; '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 :content-type; bh=M1vGB/G7BqbitcQrMFfWiMXy4CW8tvMqJTzdjSlNX+U=; b=JHLmkZU2jkaYqR4oshM4CP4T6q4VMcoYZ05aXGF4NOewyJ0ynU5uZGT2fz/hC5Dqx6 z+rgkJE6ty0VWU9XIp2nQcjwoYzHi9wq9rNUiQLK7BXUmZDc8KxPJus0mZYknS2RnLu6 OElz6wXmFijtPaoZWUwMUfJcHKvC7l1HKoDEss9O2+p9JqJypQ/gVrrkbep9Aj9m4rqN tz3blUngcKd7pfrZLvm4/ex9YRpaiTDfdzGZDBDjEdFSGITIUkmfI9mXftSObIHh2A9F 91Chn5C6BZH2L5IHL0aMQwaELmUi9xRIvq0N7DSAbgpbJ33PGDZzU3y60uBtAs4OCnw0 BaUw==
X-Received by 10.66.230.199 with SMTP id ta7mr4948120pac.153.1369854884182; Wed, 29 May 2013 12:14:44 -0700 (PDT)
MIME-Version 1.0
In-Reply-To <17dc2765-bc59-407a-9227-d67572411ad1@googlegroups.com>
References <17dc2765-bc59-407a-9227-d67572411ad1@googlegroups.com>
From Ian Kelly <ian.g.kelly@gmail.com>
Date Wed, 29 May 2013 13:14:03 -0600
Subject Re: python b'...' notation
To Python <python-list@python.org>
Content-Type text/plain; charset=ISO-8859-1
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.2377.1369854893.3114.python-list@python.org> (permalink)
Lines 7
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1369854893 news.xs4all.nl 15909 [2001:888:2000:d::a6]:48328
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:46408

Show key headers only | View raw


On Wed, May 29, 2013 at 12:33 PM, alcyon <steve@terrafirma.us> wrote:
> This notation displays hex values except when they are 'printable', in which case it displays that printable character.  How do I get it to force hex for all bytes?  Thanks, Steve

Is this what you want?

>>> ''.join('%02x' % x for x in b'hello world')
'68656c6c6f20776f726c64'

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


Thread

python b'...' notation alcyon <steve@terrafirma.us> - 2013-05-29 11:33 -0700
  Re: python b'...' notation Ian Kelly <ian.g.kelly@gmail.com> - 2013-05-29 13:14 -0600

csiph-web