Better ways to get nth element from an unsubscriptable iterable
Just use nth
recipe from itertools
>>> from itertools import permutations, islice
>>> def nth(iterable, n, default=None):
"Returns the nth item or a default value"
return next(islice(iterable, n, None), default)
>>> print nth(permutations(range(10), 10), 1000)
(0, 1, 2, 4, 6, 5, 8, 9, 3, 7)
A more readable solution is :
next(x for i,x in enumerate(ps) if i==1000)