escape sequences in list comprehensions

Russell Blau russblau at cox.net
Fri Nov 12 08:58:19 EST 2004


"kartik" <kartick_vaddadi at yahoo.com> wrote in message 
news:940ee3e8.0411120517.488d16ca at posting.google.com...
> 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?

You're missing what happens when you print *any* list containing strings:

>>> print ['\n', '\n']
['\n', '\n']

-- 
I don't actually check my hotmail account, but you can replace hotmail with 
excite if you really want to contact me. 





More information about the Python-list mailing list