Path: csiph.com!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!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.000 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'explicitly': 0.04; 'subject:bug': 0.05; 'things.': 0.05; 'completeness': 0.07; 'utf-8': 0.07; 'encode': 0.09; 'encodes': 0.09; 'received:155': 0.09; 'str)': 0.09; 'structure,': 0.09; 'language': 0.14; 'encoding': 0.15; '(bytes': 0.16; 'decode': 0.16; 'disclaimers': 0.16; 'disclaimers,': 0.16; 'from:addr:jpmorgan.com': 0.16; 'received:155.180': 0.16; 'received:155.180.234': 0.16; 'received:159.53': 0.16; 'received:bankone.net': 0.16; 'received:exchad.jpmchase.net': 0.16; 'received:jpmchase.com': 0.16; 'received:jpmchase.net': 0.16; 'received:svr.bankone.net': 0.16; 'securities,': 0.16; 'transforming': 0.16; 'url:disclosures': 0.16; 'url:jpmorgan': 0.16; 'wrote:': 0.17; 'bytes': 0.17; '(or': 0.18; 'load': 0.19; 'appropriate': 0.20; 'translate': 0.20; 'to:name:python-list@python.org': 0.20; 'received:169.254': 0.24; 'header:In-Reply-To:1': 0.25; 'accuracy': 0.27; "doesn't": 0.28; 'correct': 0.28; 'chris': 0.28; 'dictionary': 0.29; 'fighting': 0.29; 'str': 0.29; 'convert': 0.29; 'objects': 0.29; 'received:169': 0.29; 'sense': 0.31; 'to:addr:python-list': 0.33; 'that,': 0.34; 'list': 0.35; 'doing': 0.35; 'subject:?': 0.35; 'really': 0.36; 'but': 0.36; 'data.': 0.36; 'should': 0.36; 'charset:us-ascii': 0.36; 'data': 0.37; 'subject:: ': 0.38; 'some': 0.38; 'to:addr:python.org': 0.39; 'think': 0.40; 'your': 0.60; 'kind': 0.61; "you'll": 0.62; 'perfect': 0.63; 'information,': 0.63; 'url:email': 0.63; 'legal': 0.65; 'cast': 0.65; 'reverse': 0.65; 'subject': 0.66; 'purchase': 0.67; 'sale': 0.76; 'received:169.254.8': 0.84 X-DKIM: OpenDKIM Filter v2.1.3 sz4.jpmchase.com qA9HmDI2009209 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=jpmorgan.com; s=smtpout; t=1352483293; bh=YHOSEEVJYDYb+WbupdKGvTdHaqsl60QpYdW/mrId/L8=; h=From:To:Subject:Date:Message-ID:References:In-Reply-To: Content-Transfer-Encoding:MIME-Version:Content-Type; b=TADsp3J6ZBT1BTEUJVZvneKLIJctOiWPNj1GcFfNbiWP99rnX505LRzWCbGYIsvyA /NiP99WFDpaWS37lRckQxcXVJVT9WtlA7/5LeBzxOOt82OdtZvr0gFiJTKlMQTOJAU 4nk5cIPTylvHDSH046I7bz0R7DsWQzmzUwoj2MtM= From: "Prasad, Ramit" To: "python-list@python.org" Subject: RE: Python3.3 str() bug? Thread-Topic: Python3.3 str() bug? Thread-Index: AQHNvnTbEEqbLK5ODE2Py6JEAAKvzZfhxxZA Date: Fri, 9 Nov 2012 17:47:51 +0000 References: In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.67.79.47] Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-DLP-FWD: Yes Content-Type: text/plain; charset="us-ascii" 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: 20 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1352483296 news.xs4all.nl 6966 [2001:888:2000:d::a6]:39722 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:33044 Chris Angelico wrote:=0D=0A> =0D=0A> What you really should be doing is not= transforming the whole=0D=0A> structure, but explicitly transforming each = part inside it=2E I=0D=0A> recommend you stop fighting the language and sta= rt thinking about your=0D=0A> data as either *bytes* or *characters* and us= ing the appropriate data=0D=0A> types (bytes or str) everywhere=2E You'll t= hen find that it makes=0D=0A> perfect sense to explicitly translate (en/dec= ode) from one to another,=0D=0A> but it doesn't make sense to encode a list= in UTF-8 or decode a=0D=0A> dictionary from Latin-1=2E=0D=0A> =0D=0A[snip]= =0D=0A> =0D=0A> You may be able to do some kind of recursive cast that, in = one sweep=0D=0A> of your data structure, encodes all str objects into bytes= using a=0D=0A> given encoding (or the reverse thereof)=2E But I don't thin= k this is the=0D=0A> best way to do things=2E=0D=0A=0D=0AI would think the = best way is to convert as you load the data=2E=0D=0AThat way everything is = in the correct format as you manipulate=0D=0Aand generate new data=2E=0D=0A= =0D=0A =0D=0A~Ramit=0D=0A=0D=0A=0D=0AThis email is confidential and subject= to important disclaimers and=0D=0Aconditions including on offers for the p= urchase or sale of=0D=0Asecurities, accuracy and completeness of informatio= n, viruses,=0D=0Aconfidentiality, legal privilege, and legal entity disclai= mers,=0D=0Aavailable at http://www=2Ejpmorgan=2Ecom/pages/disclosures/email= =2E