Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #33036
| Path | csiph.com!usenet.pasdenom.info!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <python-python-list@m.gmane.org> |
| 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; 'python3': 0.05; 'subject:bug': 0.05; 'things.': 0.05; 'type,': 0.07; 'utf-8': 0.07; 'works.': 0.07; 'python': 0.09; '(complex)': 0.09; 'encode': 0.09; 'encodes': 0.09; 'parameter.': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'str)': 0.09; 'structure,': 0.09; 'useless': 0.09; 'language': 0.14; 'encoding': 0.15; '"general': 0.16; '(bytes': 0.16; '(more': 0.16; 'concatenate': 0.16; 'decode': 0.16; 'does;': 0.16; 'from:addr:behnel.de': 0.16; 'from:addr:stefan_ml': 0.16; 'from:name:stefan behnel': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'repr()': 0.16; 'stdlib.': 0.16; 'str()': 0.16; 'transforming': 0.16; 'string': 0.17; 'wrote:': 0.17; 'bytes': 0.17; 'stefan': 0.17; 'unicode': 0.17; 'thanks,': 0.18; '>>>': 0.18; '(or': 0.18; 'appropriate': 0.20; 'translate': 0.20; 'ctypes': 0.22; 'script': 0.24; 'pass': 0.25; 'header:In- Reply-To:1': 0.25; 'header:User-Agent:1': 0.26; 'converting': 0.27; 'library.': 0.27; 'structures': 0.27; "doesn't": 0.28; 'header:X-Complaints-To:1': 0.28; 'chris': 0.28; 'run': 0.28; 'dictionary': 0.29; 'fighting': 0.29; 'str': 0.29; 'case,': 0.29; 'objects': 0.29; 'fri,': 0.30; 'returned': 0.30; 'function': 0.30; 'sense': 0.31; '(and': 0.32; 'received:84': 0.32; 'problem': 0.33; 'to:addr:python-list': 0.33; 'that,': 0.34; 'list': 0.35; 'nov': 0.35; 'doing': 0.35; 'subject:?': 0.35; 'something': 0.35; 'there': 0.35; 'received:org': 0.36; 'really': 0.36; 'but': 0.36; 'should': 0.36; 'does': 0.37; 'level': 0.37; 'data': 0.37; 'subject:: ': 0.38; 'object': 0.38; 'some': 0.38; 'to:addr:python.org': 0.39; 'called': 0.39; 'header:Received:5': 0.40; 'think': 0.40; 'your': 0.60; 'further': 0.61; 'kind': 0.61; "you'll": 0.62; 'different': 0.63; 'perfect': 0.63; 'more': 0.63; 'cast': 0.65; 'reverse': 0.65; 'forward': 0.66; 'special': 0.73; 'found?': 0.84; 'received:arcor-ip.net': 0.84; 'received:pools .arcor-ip.net': 0.84; 'substrings': 0.84 |
| X-Injected-Via-Gmane | http://gmane.org/ |
| To | python-list@python.org |
| From | Stefan Behnel <stefan_ml@behnel.de> |
| Subject | Re: Python3.3 str() bug? |
| Date | Fri, 09 Nov 2012 18:07:51 +0100 |
| References | <ag402kFkb9hU1@mid.dfncis.de> <mailman.3483.1352453842.27098.python-list@python.org> <ag46guFkb9hU2@mid.dfncis.de> <mailman.3489.1352463727.27098.python-list@python.org> <ag4dsmFn6uuU1@mid.dfncis.de> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=UTF-8 |
| Content-Transfer-Encoding | 7bit |
| X-Gmane-NNTP-Posting-Host | dslb-084-056-057-031.pools.arcor-ip.net |
| User-Agent | Mozilla/5.0 (X11; Linux x86_64; rv:16.0) Gecko/20121028 Thunderbird/16.0.2 |
| In-Reply-To | <ag4dsmFn6uuU1@mid.dfncis.de> |
| 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.3502.1352480884.27098.python-list@python.org> (permalink) |
| Lines | 44 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1352480884 news.xs4all.nl 6926 [2001:888:2000:d::a6]:43207 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:33036 |
Show key headers only | View raw
Helmut Jarausch, 09.11.2012 14:13: > On Fri, 09 Nov 2012 23:22:04 +1100, Chris Angelico wrote: >> What you really should be doing is not transforming the whole >> structure, but explicitly transforming each part inside it. I >> recommend you stop fighting the language and start thinking about your >> data as either *bytes* or *characters* and using the appropriate data >> types (bytes or str) everywhere. You'll then find that it makes >> perfect sense to explicitly translate (en/decode) from one to another, >> but it doesn't make sense to encode a list in UTF-8 or decode a >> dictionary from Latin-1. >> >>> This problem has arisen while converting a working Python2 script to Python3.3. >>> Since Python2 doesn't have bytestrings it just works. >> >> Actually it does; it just calls them "str". And there's a Unicode >> string type, called "unicode", which is (more or less) the thing that >> Python 3 calls "str". >> >> You may be able to do some kind of recursive cast that, in one sweep >> of your data structure, encodes all str objects into bytes using a >> given encoding (or the reverse thereof). But I don't think this is the >> best way to do things. > > Thanks, but in my case the (complex) object is returned via ctypes from the > aspell library. > I still think that a standard function in Python3 which is able to 'stringify' > objects should take an encoding parameter. And how would that work? Would it recursively run through all data structures you pass in or stop at some level or at some type of object? Would it simply concatenate the substrings (and with what separator?), or does the chaining depend on the objects found? Should it use the same separator for everything or different separators for each level of the data structure? Should it use str() for everything or repr() for some? Is str() the right thing or are there special objects that need more than just a call to str(), some kind of further preprocessing? There are so many ways to do something like this, and it's so straight forward to do in a given use case, that it's IMHO useless to even think about adding a "general solution" for this to the stdlib. Stefan
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Python3.3 str() bug? Helmut Jarausch <jarausch@igpm.rwth-aachen.de> - 2012-11-09 09:18 +0000
Re: Python3.3 str() bug? Stefan Behnel <stefan_ml@behnel.de> - 2012-11-09 10:37 +0100
Re: Python3.3 str() bug? Helmut Jarausch <jarausch@igpm.rwth-aachen.de> - 2012-11-09 11:08 +0000
Re: Python3.3 str() bug? Chris Angelico <rosuav@gmail.com> - 2012-11-09 23:22 +1100
Re: Python3.3 str() bug? Helmut Jarausch <jarausch@igpm.rwth-aachen.de> - 2012-11-09 13:13 +0000
Re: Python3.3 str() bug? Stefan Behnel <stefan_ml@behnel.de> - 2012-11-09 18:07 +0100
Re: Python3.3 str() bug? Terry Reedy <tjreedy@udel.edu> - 2012-11-09 18:35 -0500
RE: Python3.3 str() bug? "Prasad, Ramit" <ramit.prasad@jpmorgan.com> - 2012-11-09 17:47 +0000
Re: Python3.3 str() bug? Oscar Benjamin <oscar.j.benjamin@gmail.com> - 2012-11-10 16:45 +0000
Re: Python3.3 str() bug? Ian Kelly <ian.g.kelly@gmail.com> - 2012-11-09 10:25 -0700
csiph-web