On Thu, Dec 2, 2010 at 03:13, Alan Gauld <[email protected]> wrote: > > "Richard D. Moores" <[email protected]> wrote > >>>>> s = [.1,.1,.1,.1,.1,.1,.1,.1,.1,.1] >>>>> sum(s) >> >> 0.9999999999999999 > > This uses repr() to display the result > >>>>> print(sum(s)) >> >> 1.0 Why? > > This uses str() to display the result. > > In many cases str() calls repr() but in other cases str() is a more user > friendly format. repr() tends to be a developers eye view of things. > This is one reason that in my tutorial I always use print() to display > results. The output is more newbie friendly that way :-) > > I suspect the details will be revealed by a search for documentation > on __repr__
I found nothing that helped as much as you have already. Thanks, Dick _______________________________________________ Tutor maillist - [email protected] To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
