[Python-Dev] Round Bug in Python 1.6? (str vs. repr)

Ted Horst Ted.Horst at wdr.com
Fri Apr 7 11:06:07 EDT 2000


On Fri, 7 Apr 2000, Greg Ward wrote:
> On 07 April 2000, Mikael Olofsson said:
> >
> > On 07-Apr-00 Greg Ward wrote:
> >  > Oh, joy! oh happiness! someday soon, I may be able to type
> >  > "blah.__doc__" at the interactive prompt and get a readable result!
> >
> > Just i case... I hope you haven't missed "print blah.__doc__".
>
> Yeah, I know: my usual mode of operation is this:
>
>   >>> blah.__doc__
> ...repr of docstring...
> ...sound of me cursing...
>   >>> print blah.__doc__
>
> The real reason for using str() at the interactive prompt is not to save
> me keystrokes, but because it just seems like the sensible thing to do.
> People who understand the str/repr difference, and really want the repr
> version, can slap backquotes around whatever they're printing.
>
> Greg
>
> --
> <http://www.python.org/mailman/listinfo/python-list

I share your frustration with __doc__, but I really prefer to see repr in  
the interactive interpreter.  The reason is that I like to know what kind of  
object I am looking at.  I have a tendency to call functions or methods and  
look at what they return before I decide to assign them to a variable (with  
x = _).  This technique would be less useful if I can't tell by looking at  
the return value what it is.  This is especially true for strings where you  
can see the quote.

Maybe its just me, though.

-----------------------------
Ted Horst <Ted.Horst at wdr.com>




More information about the Python-list mailing list