printing a sequence...
Peter Otten
__peter__ at web.de
Fri Jul 16 06:44:08 EDT 2004
Peter Otten wrote:
> Florian Preknya wrote:
>> What I want to obtain is [value: 10, value: 12, value: 2].
>> Can I write somehow the print statement to force calling the A.__str__
>> function?
>
> print map(str, a)
>
> or
>
> print [str(item) for item in a]
Oops, the above will still print the representation of the strings. When you
don't want quotes and escaped non-ascii characters, use
print "[%s]" % ", ".join(map(str, a))
Peter
More information about the Python-list
mailing list