Is there a more syntactically concise way of writing the following?
gen = (i for i in xrange(10))
index = 5
for i, v in enumerate(gen):
if i is index:
return v
It seems almost natural that a generator should have a gen[index]
expression, that acts as a list, but is functionally identical to the above code.