Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #81145
| Path | csiph.com!usenet.pasdenom.info!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed2a.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <rosuav@gmail.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.001 |
| X-Spam-Evidence | '*H*': 1.00; '*S*': 0.00; 'true,': 0.05; '21,': 0.07; 'float': 0.07; 'string': 0.09; 'converted': 0.09; 'encode': 0.09; 'operand': 0.09; "people's": 0.09; 'subject:2.7': 0.09; 'yeah,': 0.09; 'cc:addr:python-list': 0.11; 'python': 0.11; '(both': 0.16; 'blindly': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'operator.': 0.16; 'string)': 0.16; 'stuff.': 0.16; 'subject:unicode': 0.16; 'two,': 0.16; 'typeerror:': 0.16; 'unicode.': 0.16; 'subject:python': 0.16; 'wrote:': 0.18; 'bit': 0.19; '3.0': 0.19; 'result.': 0.19; 'thu,': 0.19; '>>>': 0.22; 'cc:addr:python.org': 0.22; 'adds': 0.24; 'bytes': 0.24; 'lets': 0.24; 'unicode': 0.24; 'cc:2**0': 0.24; '2.0': 0.26; 'header:In- Reply-To:1': 0.27; 'chris': 0.29; 'am,': 0.29; 'message- id:@mail.gmail.com': 0.30; '(which': 0.31; '"",': 0.31; 'convenience': 0.31; 'object.': 0.31; 'safely': 0.31; 'file': 0.32; '(most': 0.33; 'fri,': 0.33; 'subject:time': 0.33; 'sense': 0.34; 'subject: (': 0.35; "can't": 0.35; 'but': 0.35; 'received:google.com': 0.35; 'subject:one': 0.36; 'should': 0.36; 'nov': 0.38; 'rather': 0.38; 'recent': 0.39; 'does': 0.39; 'expensive': 0.39; 'break': 0.61; 'subject:more': 0.64; 'more': 0.64; '20,': 0.68; 'acts': 0.74; 'special': 0.74; '2014,': 0.84; 'complaint': 0.84; 'complexity': 0.84; 'type(s)': 0.84; 'careful': 0.91; 'cognitive': 0.91; 'to:none': 0.92; 'hand,': 0.93 |
| 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:cc :content-type; bh=RRX6ffwETkTYGCL+uNGef5YGNm86trsVcHRCr11CLkw=; b=vzrzUzvNsScfvHA26VVf5sZ0T1w0sPsB2nKvKYSA8IXYy/eI9murgobNeGIf3nhmhT m0uHrG+Zim5MbzYR1cWwZ7IThqbLa4FbAtbnri4Gvc8dgvYArRHrBju8AUF4i7LXZFxq DZYA9bWSxVD3ZQgUDDSV90nlaiqmjfOjGebegau6/kaA6raBVXChIyW9/Xtv13dEZiJs 5mEdcqjrxL7uFBw7T1o5JbNp4RJXI3Yxx4zF2pAdljx8e5qqAXx81gekmSZ3QhsJCLZl ISmfWtOYz9gffe22KJz4W7QPX5QiEN0kppiOrQDRCynYF6GfV3pTGxpWdaalSTL/pR4h X4JQ== |
| MIME-Version | 1.0 |
| X-Received | by 10.42.128.81 with SMTP id l17mr6223719ics.8.1416526894726; Thu, 20 Nov 2014 15:41:34 -0800 (PST) |
| In-Reply-To | <1416505379.268157.193439717.66E319D4@webmail.messagingengine.com> |
| References | <m4kcu8$ta8$1@ger.gmane.org> <m4kn66$ma3$1@ger.gmane.org> <1416491999.209592.193345213.3A6FF9A4@webmail.messagingengine.com> <CAPTjJmr5NWMFCfU8jaNd2g2f9cQ1y+zO3qT7yVcC_m9vKXN6fw@mail.gmail.com> <1416505379.268157.193439717.66E319D4@webmail.messagingengine.com> |
| Date | Fri, 21 Nov 2014 10:41:34 +1100 |
| Subject | Re: python 2.7 and unicode (one more time) |
| From | Chris Angelico <rosuav@gmail.com> |
| Cc | "python-list@python.org" <python-list@python.org> |
| Content-Type | text/plain; charset=UTF-8 |
| 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 | <https://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 | <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.16065.1416526902.18130.python-list@python.org> (permalink) |
| Lines | 42 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1416526902 news.xs4all.nl 2882 [2001:888:2000:d::a6]:38375 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:81145 |
Show key headers only | View raw
On Fri, Nov 21, 2014 at 4:42 AM, <random832@fastmail.us> wrote: > On Thu, Nov 20, 2014, at 09:59, Chris Angelico wrote: >> >> Why should it encode to bytes? > > Because a bytes format string suggests a bytes result. Why does unicode > always "win", rather than the type of the format string always winning? For the same reason that float always "wins": >>> 1.0 + 2 3.0 >>> 1 + 2.0 3.0 >> Makes much better sense to work in >> Unicode. But mainly, it has to do one of them, and be predictable. > > Yeah, but string % is not a symmetrical operator. People's mental model > of it is likely to be that it acts like format (which does use the type > of the format string) or C sprintf/wsprintf (both of which use the same > type for the format string and result). And literally every other type > is converted to the type of the format string when used with %s - having > unicode be special adds cognitive load, and it means you can't safely > blindly use %s with an unknown object. True, but Python 2 deliberately lets you conflate the two, so you get a bit of convenience at the expensive of complexity when things go wrong. Python 3, on the other hand, is much more careful about the difference: >>> "asdf %s qwer" % b"zxcv" "asdf b'zxcv' qwer" >>> b"asdf %s qwer" % "zxcv" Traceback (most recent call last): File "<stdin>", line 1, in <module> TypeError: unsupported operand type(s) for %: 'bytes' and 'str' So your complaint *has* been resolved... but only in Python 3, because the change would break stuff. ChrisA
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: python 2.7 and unicode (one more time) Chris Angelico <rosuav@gmail.com> - 2014-11-21 10:41 +1100
csiph-web