Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #56739

Re: Unicode Objects in Tuples

Path csiph.com!usenet.pasdenom.info!gegeweb.org!usenet-fr.net!nerim.net!novso.com!newsfeed.xs4all.nl!newsfeed1.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <nedbat@gmail.com>
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; 'programmer': 0.03; '(at': 0.04; 'resulting': 0.04; 'syntax': 0.04; 'interpreter': 0.05; 'root': 0.05; 'developer.': 0.07; 'string': 0.09; 'agree,': 0.09; 'instances.': 0.09; 'literal': 0.09; 'used.': 0.09; 'useless': 0.09; 'vast': 0.09; 'cc:addr:python-list': 0.11; 'python': 0.11; 'itself.': 0.14; '(sorry': 0.16; 'expression,': 0.16; 'hierarchy,': 0.16; 'interpreter,': 0.16; 'itself,': 0.16; 'object()': 0.16; 'ought': 0.16; 'repr': 0.16; 'spurious': 0.16; 'subject:Unicode': 0.16; 'tuple': 0.16; 'tuples,': 0.16; 'unambiguous': 0.16; 'utterly': 0.16; ':-)': 0.16; 'sender:addr:gmail.com': 0.17; 'wrote:': 0.18; 'possible,': 0.19; 'meant': 0.20; 'seems': 0.21; '>>>': 0.22; 'cc:addr:python.org': 0.22; 'header:User-Agent:1': 0.23; '2.x': 0.24; 'helper': 0.24; 'stephen': 0.24; 'cc:2**0': 0.24; 'least': 0.26; 'header:In-Reply- To:1': 0.27; 'idea': 0.28; 'function': 0.29; 'am,': 0.29; "doesn't": 0.30; 'compared': 0.30; 'object.': 0.31; 'fri,': 0.33; 'programmers': 0.33; 'could': 0.34; 'classes': 0.35; 'something': 0.35; 'equal': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'there': 0.35; 'really': 0.36; 'acceptable': 0.36; 'possible': 0.36; 'should': 0.36; 'too': 0.37; 'two': 0.37; 'question,': 0.38; 'that,': 0.38; 'little': 0.38; 'explain': 0.39; 'how': 0.40; 'even': 0.60; 'flat': 0.60; 'ian': 0.60; 'most': 0.60; 'more': 0.64; 'to:addr:gmail.com': 0.65; 'between': 0.67; 'fact,': 0.69; 'different.': 0.84; 'differently:': 0.84; 'distinguish': 0.84; 'otten': 0.84; 'difficult,': 0.91; '2013': 0.98
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:message-id:date:from:user-agent:mime-version:to:cc:subject :references:in-reply-to:content-type:content-transfer-encoding; bh=zsS0RQ1/uCSxNGEONgQnWKX/OV+HR1leGsiBOlv1pgk=; b=I2JUAMck3N562EZrK+ZzhkwFxD12I069aac7cqAFTE1QNF3zUs5/KmeYk7TYP+U9HE e+x9HpwMU2+KXPmdBaNoXHXoZihIThGrMYL5m87TIP1JZQdWYUN57/sWFCgRjKx1FMXo VG6dzyv39WLardnQt91eQ+0tGXZLyRvbnG4mB9HSX0nSnjpTCkRiIGDPIoFHIHvQQqH5 F9MuE1QMUM9Cc2h7yOz69EFYr+XWdcBzv20sG/OYrHhLFzZ2FY0ehbhiVCxQwqSM3OFI FnkQQLD1xmmgFsdcnR5/IEbSVbpyb306tUxoIBIBsqPB9XsX/GyumFu5R7NP6Mw4EkxB PPdw==
X-Received by 10.49.130.132 with SMTP id oe4mr914235qeb.86.1381575139985; Sat, 12 Oct 2013 03:52:19 -0700 (PDT)
Sender Ned Batchelder <nedbat@gmail.com>
Date Sat, 12 Oct 2013 06:52:19 -0400
From Ned Batchelder <ned@nedbatchelder.com>
User-Agent Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:17.0) Gecko/20130801 Thunderbird/17.0.8
MIME-Version 1.0
To Ian Kelly <ian.g.kelly@gmail.com>
Subject Re: Unicode Objects in Tuples
References <CAP=-cKU6Xkt_rm4VYh7NfXLSfUDG7FZQXHz+U12gP6fbkdhxbQ@mail.gmail.com> <5257C35C.4070407@nedbatchelder.com> <CAP=-cKVJ10KmWCnc8-86KabXL=EmCSUJpO=jDVBpXmRPH1hHBg@mail.gmail.com> <CALwzidmtkaD9swOcEipvXSmeP-qooBSY=4Qd0NwRTMx9D5e7Rw@mail.gmail.com>
In-Reply-To <CALwzidmtkaD9swOcEipvXSmeP-qooBSY=4Qd0NwRTMx9D5e7Rw@mail.gmail.com>
Content-Type text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding 7bit
Cc Python <python-list@python.org>
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.1034.1381575143.18130.python-list@python.org> (permalink)
Lines 40
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1381575143 news.xs4all.nl 15865 [2001:888:2000:d::a6]:35668
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:56739

Show key headers only | View raw


On 10/12/13 2:20 AM, Ian Kelly wrote:
> On Fri, Oct 11, 2013 at 7:31 AM, Stephen Tucker <stephen_tucker@sil.org> wrote:
>> On the original question, well, I accept Ned's answer (at 10.22). I also
>> like the idea of a helper function given by Peter Otten at 09.51. It still
>> seems like a crutch to help poor old Python 2.X to do what any programmer
>> (or, at least the programmers like me :-)  ) think it ought to be able to by
>> itself. The distinction between the "geekiness" of a tuple compared with the
>> "non-geekiness" of a string is, itself, far too geeky for my liking. The
>> distinction seems to be an utterly spurious - even artificial or arbitrary
>> one to me. (Sorry about the rant.)
> I agree, and that's not how I would explain the distinction.  The str
> of an object is meant to be human-readable, while the repr of an
> object is meant to be something that could be pasted into the
> interpreter to reconstruct the object.  In the case of tuples, the
> repr of the tuple uses the reprs of the components because the
> resulting string will more likely be acceptable to the interpreter,
> and the str of the tuple is the same as the repr because there is no
> convincing reason why it should be different.

This idea that the repr can reconstruct the object always fell flat with 
me since the vast majority of classes don't have a repr that works that 
way.  I look at it a little differently: the repr is meant to be as 
unambiguous as possible to a developer.  It turns out that Python 
literal syntax is really good at that, so where possible, that's what's 
used.   But most classes don't make an attempt to create a Python 
expression, because that's very difficult, and in fact, the literal 
syntax may not be useful:

     >>> object()
     <object object at 0x1088bb0d0>

Here, the valid Python syntax is "object()", but that's useless as a 
repr, because it doesn't help you distinguish between two instances.

In fact, you say repr could be used to "reconstruct the object", but 
really what you mean is "reconstruct an equal object".  There is no way 
to construct an equal object(), so right at the root of the Python 
object hierarchy, repr doesn't even attempt it.

--Ned.

Back to comp.lang.python | Previous | NextNext in thread | Find similar | Unroll thread


Thread

Re: Unicode Objects in Tuples Ned Batchelder <ned@nedbatchelder.com> - 2013-10-12 06:52 -0400
  Re: Unicode Objects in Tuples Roy Smith <roy@panix.com> - 2013-10-12 09:11 -0400

csiph-web