On Jun 13, 3:59 pm, Arnaud Delobelle <arno...@googlemail.com> wrote: > kj <no.em...@please.post> writes: > > Are these the most idiomatically pythonic forms? Or am > > I missing something better? > > You're missing operator.itemgetter: > > >>> from operator import itemgetter > >>> foo = "spam & eggs" > >>> itemgetter(3, 7, 1, -1)(foo) > > ('m', 'e', 'p', 's')
That looks to me like the best solution to the OP's specific question. It's amazing how many cool things are tucked into the standard library. While it's easy to miss these things, I appreciate the effort to keep Python's core relatively small. (Not knowing about itemgetter, I would have gone with the list comprehension.) John -- http://mail.python.org/mailman/listinfo/python-list