escape sequences in list comprehensions
zanesdad at bellsouth.net
Fri Nov 12 14:54:23 CET 2004
>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?
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?
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Python-list