Elegant way to skip elements in an iterable
问题 I've got a large iterable, in fact, a large iterable given by: itertools.permutations(range(10)) I would like to access to the millionth element. I alredy have problem solved in some different ways. Casting iterable to list and getting 1000000th element: return list(permutations(range(10)))[999999] Manually skiping elements till 999999: p = permutations(range(10)) for i in xrange(999999): p.next() return p.next() Manually skiping elements v2: p = permutations(range(10)) for i, element in