From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 27709 invoked by alias); 10 Nov 2009 15:53:21 -0000 Mailing-List: contact archer-help@sourceware.org; run by ezmlm Sender: Precedence: bulk List-Post: List-Help: List-Subscribe: List-Id: Received: (qmail 27690 invoked by uid 22791); 10 Nov 2009 15:53:20 -0000 X-SWARE-Spam-Status: No, hits=-2.2 required=5.0 tests=AWL,BAYES_00,SPF_PASS X-Spam-Check-By: sourceware.org X-Loopcount0: from 12.110.134.31 Content-class: urn:content-classes:message MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Subject: RE: [python] Pretty-printers and addressprint Date: Tue, 10 Nov 2009 15:53:00 -0000 Message-ID: In-Reply-To: <8ac60eac0911100744t5335a44fn7175e2d5c512e450@mail.gmail.com> References: <20091110021158.C3C2576D70@ppluzhnikov.mtv.corp.google.com> <58596C4646708B4BB990C44839973330013A61DE@usplmvpbe001.ent.rt.verigy.net> <8ac60eac0911100006yc31e2acmba7bf9fde33ddfa@mail.gmail.com> <8ac60eac0911100744t5335a44fn7175e2d5c512e450@mail.gmail.com> From: "Paul Koning" To: "Paul Pluzhnikov" Cc: "Elmenthaler, Jens" , , , X-SW-Source: 2009-q4/txt/msg00053.txt.bz2 repr() is a Python builtin function that returns the "representation" of an object -- a string that matches the representation of that object in Python. Contrast that with str() which prints it the user-friendly way which may be less complete. For example: python Python 2.5.1 (r251:54863, Feb 6 2009, 19:02:12)=20 >>> foo=3D"abc\1" >>> print foo abc >>> print repr(foo) 'abc\x01' >>> print str(foo) abc >>>=20=20 Note that "repr" puts quotes around the string, and escapes the non-printable characters. It also escapes quotes, which simply wrapping a quote around the raw string won't cover. If in gdb repr() doesn't work as in standard Python that would be a problem... paul > -----Original Message----- > From: Paul Pluzhnikov [mailto:ppluzhnikov@google.com] > Sent: Tuesday, November 10, 2009 10:45 AM > To: Paul Koning > Cc: Elmenthaler, Jens; gdb@sourceware.org; archer@sourceware.org; > dje@google.com > Subject: Re: [python] Pretty-printers and addressprint >=20 > On Tue, Nov 10, 2009 at 3:53 AM, Paul Koning > wrote: >=20 > >> Unfortunately I frequently deal with non-ascii strings, and the > >> problem just wouldn't go away :-( > > > > My test (without gdb, I don't have that installed yet) is > inconclusive > > but I think using repr() will cure that too. >=20 > AFAICT, in GDB repr(value) is a no-op, and the end result of returning > repr(value) from the pretty-printer is exactly the same as that of > returning the value itself: >=20 > $4 =3D 0x4007e0 "this is x\201\202\203\204" >=20 > Should repr(value) do something different? >=20 > Thanks, > -- > Paul Pluzhnikov