This is the mail archive of the archer@sourceware.org mailing list for the Archer project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

RE: [python] Pretty-printers and addressprint


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) 
>>> foo="abc\1"
>>> print foo
abc
>>> print repr(foo)
'abc\x01'
>>> print str(foo)
abc
>>>  

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
> 
> On Tue, Nov 10, 2009 at 3:53 AM, Paul Koning <Paul_Koning@dell.com>
> wrote:
> 
> >> 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.
> 
> 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:
> 
>   $4 = 0x4007e0 "this is x\201\202\203\204"
> 
> Should repr(value) do something different?
> 
> Thanks,
> --
> Paul Pluzhnikov


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]