Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder.erje.net!newsfeed.xs4all.nl!newsfeed6.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.013 X-Spam-Evidence: '*H*': 0.97; '*S*': 0.00; 'subject:data': 0.07; 'bytes.': 0.09; 'bytes;': 0.09; 'level,': 0.09; 'subject:string': 0.09; 'python': 0.11; 'encoding.': 0.16; 'filename': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'subject:changing': 0.16; "would've": 0.16; '\xa0what': 0.16; 'python?': 0.18; 'sorry,': 0.18; 'fri,': 0.18; 'trying': 0.20; '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; 'message-id:@mail.gmail.com': 0.27; 'push': 0.27; 'file': 0.29; "doesn't": 0.30; 'received:209.85': 0.32; 'received:209.85.210': 0.32; 'chris': 0.32; 'received:google.com': 0.32; 'subject: (': 0.33; 'bytes': 0.33; 'encoding': 0.33; 'received:209': 0.35; 'there': 0.35; 'characters': 0.35; 'lists': 0.35; 'subject:)': 0.36; 'does': 0.36; '(in': 0.37; 'that,': 0.37; 'some': 0.37; 'actual': 0.38; 'called': 0.38; 'open': 0.38; 'expect': 0.39; 'handle': 0.39; "can't": 0.39; 'to:addr:python-list': 0.39; 'to:addr:python.org': 0.40; 'mar': 0.61; 'more': 0.63; 'inside': 0.65; 'simply': 0.65; '2012': 0.69; '30,': 0.70; 'series': 0.80; 'impossible': 0.84; 'kool-aid': 0.84 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=bBZSgr9lbeJRt9NX4VBUBPFEMIQaJV9yxPGyqqLvyh8=; b=egrabWHMXml2IpRbl3Bg+1ddoAs5KyE0p5JkIqSPjHcs0yfzku/pnJsJZtStIYO5ps zBSFIkUJVDA3I1f4nmsre6t6BDIbNwrHQTjdWo12r/gO80ZjCWXlAKVbuYf6gEfP4m8u BsRAa0nBSZ1LgAlwCSMUJXXYDL5tp5cIBFdQyofuDizf2f2g5wQxDEi46NDep1rwxmJd EDafNTEghNQvmTl6tmWNS3kpoyMnZxWzoYfgF5qp1Th4UfM9A1l1QVtyfxuwLSuoEvbe KfVHd8XxzlYoT4dXzxp7G0x+F+u8JV5Ys8PlN2z2/q7PMOGEPMx4nG8RLixetpkHKdrO L/DA== MIME-Version: 1.0 In-Reply-To: References: <9tg21lFmo3U1@mid.dfncis.de> <4f740687$0$29884$c3e8da3$5496439d@news.astraweb.com> Date: Fri, 30 Mar 2012 07:41:31 +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 Content-Transfer-Encoding: quoted-printable 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: 23 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1333053694 news.xs4all.nl 6873 [2001:888:2000:d::a6]:60977 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:22360 On Fri, Mar 30, 2012 at 5:00 AM, Ross Ridge wr= ote: > Sorry, it would've been more accurate to label the flavour of kool-aid > Chris Angelico was trying to push as "it's impossible ... without > encoding": > > =A0 =A0 =A0 =A0What is a string? It's not a series of bytes. You can't co= nvert > =A0 =A0 =A0 =A0it without encoding those characters into bytes in some wa= y. I still stand by that statement. Do you try to convert a "dictionary of filename to open file object" into a "series of bytes" inside Python? It doesn't matter that, on some level, it's *stored as* a series of bytes; the actual object *is not* a series of bytes. There is no logical equivalency, ergo it is illogical and nonsensical to expect to turn one into the other without some form of encoding. Python does include an encoding that can handle lists and dictionaries. It's called Pickle, and it returns (in Python 3) a bytes object - which IS a series of bytes. It doesn't simply return some internal representation. ChrisA