escape sequences in list comprehensions
Jeremy Jones
zanesdad at bellsouth.net
Fri Nov 12 08:54:23 EST 2004
kartik wrote:
>Escape sequences don't seem to work in strings within list comprehensions:
>
>
>>>>print ['%s\n' %i for i in [1,2,3]]
>>>>
>>>>
>['1\n', '2\n', '3\n']
>
>What am I missing?
>
>Thank you.
>
>
What are you expecting it to do? It looks like it's working fine to
me. It's giving you your list back, but converting each element to a
string, the last "piece" of which is a "\n". What were you expecting
differently from that?
Jeremy Jones
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20041112/1b85f3fb/attachment.html>
More information about the Python-list
mailing list