Path: csiph.com!usenet.pasdenom.info!news.albasani.net!feeder.erje.net!newsfeed.xs4all.nl!newsfeed5.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.025 X-Spam-Evidence: '*H*': 0.95; '*S*': 0.00; 'subject:data': 0.07; 'bytes.': 0.09; 'subject:string': 0.09; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'subject:changing': 0.16; 'string': 0.18; 'received:209.85.210.174': 0.20; 'received:mail- iy0-f174.google.com': 0.20; 'wrote:': 0.21; 'header:In-Reply- To:1': 0.22; 'convert': 0.23; 'wed,': 0.24; 'message- id:@mail.gmail.com': 0.27; 'pm,': 0.28; 'way?': 0.29; 'received:209.85': 0.32; 'received:209.85.210': 0.32; 'received:google.com': 0.32; 'subject: (': 0.33; 'hi,': 0.33; 'bytes': 0.33; 'encoding': 0.33; 'received:209': 0.35; 'there': 0.35; 'characters': 0.35; 'subject:)': 0.36; 'peter': 0.37; 'some': 0.37; 'data': 0.38; 'something': 0.38; "can't": 0.39; 'to:addr:python-list': 0.39; 'to:addr:python.org': 0.40; 'mar': 0.61; '2012': 0.69; 'series': 0.80 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; bh=5r8UpB8u+UNbcQGLuU+5uHq78Dm92aseFu859GrH8CU=; b=e7Oo2YZYhsRizLxjpzcngqtXn9LldjbVBo3JBflKeohgbSZqkL8oMqOEumCW3Uex3r sr4sKtdhl/ASpi5bQSToHZNckNkbLOrREplHXdNn24Y6M2zBxGGM0yWVzhBEY9zCGU7A xJyWrGEAX/vvNvz/YGtK63w6tzTRCIbk4P0Jt6LeIURE98Y2ZFGYXyfXitfXGoH0Q6t2 PawrG59vK7JORUvCb+LKywCp13wBMvp9zOVjGDmf/KIPWY3HyoxWirlXw7VXu5C/5heS 57octaoByZEwZo6Pqq2C3aZbg1psVyHHXTlwi/MGbSoMDqCRzFc/U2gHd52So9kPv8lc Gi6A== MIME-Version: 1.0 In-Reply-To: <9tg21lFmo3U1@mid.dfncis.de> References: <9tg21lFmo3U1@mid.dfncis.de> Date: Wed, 28 Mar 2012 20:02:42 +1100 Subject: Re: "convert" string to bytes without changing data (encoding) From: Chris Angelico To: python-list@python.org Content-Type: text/plain; charset=ISO-8859-1 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.12 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: 13 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1332925364 news.xs4all.nl 6939 [2001:888:2000:d::a6]:40189 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:22267 On Wed, Mar 28, 2012 at 7:56 PM, Peter Daum wrote: > Hi, > > is there any way to convert a string to bytes without > interpreting the data in any way? Something like: > > s='abcde' > b=bytes(s, "unchanged") What is a string? It's not a series of bytes. You can't convert it without encoding those characters into bytes in some way. ChrisA