str() inconsistency

Mark McEahern marklists at mceahern.com
Fri Jul 26 08:46:38 EDT 2002


[Mike Rovner]
> Why it's not a bug:
>
> >>> 4.4
> 4.4000000000000004
> >>> `4.4`
> '4.4000000000000004'
> >>> str(4.4)
> '4.4'
> >>> str([4.4])
> '[4.4000000000000004]'
>
> IMHO, str() shall call str, not repr on complex objects.

Apparently, this topic comes up from time to time.  I was trying to find the
most recent post from Tim Peters on this (sometime in the last two weeks, I
believe).  It may be somewhere in the results of this search:


http://groups.google.com/groups?as_q=str%20repr%20list%20bug&as_ugroup=comp.
lang.python

I did find this one from October 2000:


http://groups.google.com/groups?selm=mailman.971929189.1785.python-list%40py
thon.org

as well as Guido's post on this topic from November 1999:


http://groups.google.com/groups?selm=5lln8ht38a.fsf%40eric.cnri.reston.va.us

// mark





More information about the Python-list mailing list