for loop question

Robert Dailey rcdailey at
Wed Oct 10 21:56:10 CEST 2007


I'm currently writing my own CSV parser since the built in one doesn't
support Unicode. I'm wondering if there's a way to iterate over the
characters in a unicode string and have access to both the 'current' and the
'next' characters each iteration. For example:

test = u"Hello World"

for cur,next in test:
    print cur,next

Ideally, this would output:

'H', 'e'
'e', 'l'
'l', 'l'
'l', 'o'

Of course, the for loop above isn't valid at all. I am just giving an
example of what I'm trying to accomplish. Anyone know how I can achieve the
goal in the example above? Thanks.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the Python-list mailing list