str() representation of sequences and dicts

Kwikrick rickvandermeiden at
Tue Aug 23 14:23:49 CEST 2005

When calling str() on a sequence or dict object, the elements of the
sequence/dict will be represented as if their __repr__ method was
called. Why is this? Wouldn't it be more consistent when calling str()
on sequence to use the __str__ method of the elements in the sequence?

As it is now, I often find myself typing something like:

 print map(str, alist)

instead of just

  print str(alist)

For dicts, it's more eleborate still.

Is there a better way to deal with this?


More information about the Python-list mailing list