I had occasion to write something like this:

    for i, n in reversed(enumerate(x)): pass

Of course this fails with "TypeError: argument to reversed() must be a
sequence". I ended up using this instead:

    for i, n in zip(reversed(range(len(x))), reversed(x)): pass

This works but is extraordinarily ugly and not terribly clear. I think
it's less confusing however than:

    for i, n in zip(range(len(x)-1, -1, -1), reversed(n)): pass

How would you write this?
-- 
https://mail.python.org/mailman/listinfo/python-list

Reply via email to