str(list) calls repr() on elements?

Michael Dyck MichaelDyck at home.com
Wed Oct 18 04:04:31 EDT 2000


It seems that the built-in function 'str', when applied to a list/tuple,
constructs its result by calling 'repr' on the elements of the list/tuple,
rather than 'str'. How come?

e.g.
>> str(1L)
'1'
>> repr(1L)
'1L'
>> str( [1L] )
'[1L]'  # not '[1]'

-Michael Dyck



More information about the Python-list mailing list