Path: csiph.com!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder1.enfer-du-nord.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed4.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.003 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'steve': 0.09; 'cc:addr :python-list': 0.11; 'character.': 0.16; 'from:addr:cs': 0.16; 'from:addr:zip.com.au': 0.16; 'from:name:cameron simpson': 0.16; 'hex': 0.16; 'insofar': 0.16; 'message-id:@cskk.homeip.net': 0.16; 'notation': 0.16; 'received:211.29': 0.16; 'received:211.29.132': 0.16; 'received:optusnet.com.au': 0.16; 'received:syd.optusnet.com.au': 0.16; 'simpson': 0.16; 'subject:python': 0.16; 'thanks,': 0.17; 'wrote:': 0.18; 'wed,': 0.18; '>>>': 0.22; 'cc:addr:python.org': 0.22; 'header:User- Agent:1': 0.23; 'cc:2**0': 0.24; 'values': 0.27; 'header:In-Reply- To:1': 0.27; 'rest': 0.29; "skip:' 10": 0.31; 'continues': 0.31; 'except': 0.35; 'received:com.au': 0.36; 'charset:us-ascii': 0.36; 'displays': 0.38; 'received:211': 0.38; 'pm,': 0.38; 'how': 0.40; 'ian': 0.60; 'content-disposition:inline': 0.62; 'to:addr:gmail.com': 0.65; '2013': 0.98 Date: Thu, 30 May 2013 08:19:42 +1000 From: Cameron Simpson To: Ian Kelly Subject: Re: python b'...' notation MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) References: X-Optus-CM-Score: 0 X-Optus-CM-Analysis: v=2.0 cv=e4Ne0tV/ c=1 sm=1 a=wom5GMh1gUkA:10 a=kj9zAlcOel0A:10 a=vrnE16BAAAAA:8 a=ZtCCktOnAAAA:8 a=Nu2K-ANblZgA:10 a=pGLkceISAAAA:8 a=gThQj61ffSHIMqGZva8A:9 a=CjuIK1q_8ugA:10 a=MSl-tDqOz04A:10 a=nwh-WkCfU5YA:10 a=ChdAjXE5lkUvdteQbhpnkQ==:117 Cc: Python 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: 15 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1369866008 news.xs4all.nl 15980 [2001:888:2000:d::a6]:42918 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:46417 On 29May2013 13:14, Ian Kelly wrote: | On Wed, May 29, 2013 at 12:33 PM, alcyon 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' Not to forget binascii.hexlify. -- Cameron Simpson Every particle continues in its state of rest or uniform motion in a straight line except insofar as it doesn't. - Sir Arther Eddington