Re: a little parsing challenge ☺

jmfauth wxjmfauth at gmail.com
Wed Jul 20 03:54:22 EDT 2011


On 20 juil, 09:29, Ian Kelly <ian.g.ke... at gmail.com> wrote:

> Otherwise, here's another non-DRY solution:
>
> >>> from itertools import izip
> >>> for i, c in izip(reversed(xrange(len(s))), reversed(s)):
>
> ...
>
> Unfortunately, this is one space where there just doesn't seem to be a
> single obvious way to do it.

Well, I see. Thanks.

There is still the old, brave solution, I'm in fact using.

>>> s = 'abcd'
>>> for i in xrange(len(s)-1, -1, -1):
...     print i, s[i]
...
3 d
2 c
1 b
0 a
>>>

---

DRY?  acronym for ?



More information about the Python-list mailing list